Enum TextEdit
pub enum TextEdit {
Splice {
at: usize,
delete: usize,
insert: String,
},
ReplaceText {
text: String,
},
}Expand description
One edit of plain text. Positions count characters (Unicode scalar values), whatever the document’s own text encoding.
Variants§
Splice
Replace delete characters at at with insert: typing is a
splice that deletes nothing, Backspace one that inserts nothing.
ReplaceText
Replace the whole text with text, written as the smallest splice
that turns what the document holds into it, so a collaborator’s
concurrent typing elsewhere survives.
Implementations§
§impl TextEdit
impl TextEdit
pub fn apply_under(
&self,
doc: &mut AutoCommit,
obj: &ExId,
) -> Result<(), ActionError>
pub fn apply_under( &self, doc: &mut AutoCommit, obj: &ExId, ) -> Result<(), ActionError>
Apply this edit to the text object obj of another resource.
§Errors
Returns ActionError::Refused when obj is not a text object or
the splice reaches past the end of the text; nothing is written.
Trait Implementations§
§impl Action for TextEdit
impl Action for TextEdit
§fn apply(&self, doc: &mut AutoCommit) -> Result<(), ActionError>
fn apply(&self, doc: &mut AutoCommit) -> Result<(), ActionError>
A record’s own text, created by the first edit.
§fn locus(&self) -> ExecutionLocus
fn locus(&self) -> ExecutionLocus
Where this action prefers to run. Defaults to
ExecutionLocus::ClientLocal.§fn risk(&self) -> RiskLevel
fn risk(&self) -> RiskLevel
The consequence class of this particular value — what it would do,
not what its type can do. A generic edit action classifies each value
(deleting a clip is
Destructive,
trimming one is not), and the host asks for the same confirmation a
declared destructive action gets whenever
requires_confirmation
holds. Must be a pure function of self. Defaults to
Low.§fn inverse_before(&self, doc: &AutoCommit) -> Option<Self>where
Self: Sized,
fn inverse_before(&self, doc: &AutoCommit) -> Option<Self>where
Self: Sized,
The document action that undoes this one when
apply records an
outside consequence in the document (an outbox entry, a filesystem op
queue). Computed against the document before this action runs, so a
delete can still read the row it removes. Read more§fn inverse_encoded(&self, doc: &AutoCommit) -> Option<EncodedAction>
fn inverse_encoded(&self, doc: &AutoCommit) -> Option<EncodedAction>
inverse_before as an encoded action, so the
door can undo through apply after the concrete type has been erased. Read more§fn change_kind(&self) -> ChangeKind
fn change_kind(&self) -> ChangeKind
Whether this value changes the document’s content or is housekeeping
about it (a read marker, a reading position). The executor writes it
into the change’s
ActionContext, where a
workspace activity feed reads it. Must be a pure function of self.
Defaults to Content.§fn action_kind(&self) -> ActionKind
fn action_kind(&self) -> ActionKind
§fn incoming_message(&self) -> bool
fn incoming_message(&self) -> bool
Whether this value records a message someone received (a chat post,
a delivered mail). The executor marks its change with
INCOMING_MESSAGE_FACET. Must be a
pure function of self.§fn describe(&self, doc: &AutoCommit) -> Option<Described>
fn describe(&self, doc: &AutoCommit) -> Option<Described>
What this value does and to which item, as history records it: a
field edit with its values before and after, a verb with its plain
arguments, or a group of those. Read from
doc as it is before the
value applies, on the origin only; replicas replay it with the
change. None lets the executor describe the value as the verb its
encoded form names (crate::Described::from_encoded).§impl<'de> Deserialize<'de> for TextEdit
impl<'de> Deserialize<'de> for TextEdit
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<TextEdit, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<TextEdit, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
§impl Serialize for TextEdit
impl Serialize for TextEdit
§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl Eq for TextEdit
impl StructuralPartialEq for TextEdit
Auto Trait Implementations§
impl Freeze for TextEdit
impl RefUnwindSafe for TextEdit
impl Send for TextEdit
impl Sync for TextEdit
impl Unpin for TextEdit
impl UnsafeUnpin for TextEdit
impl UnwindSafe for TextEdit
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more