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 member’s
concurrent typing elsewhere survives.
Implementations§
Source§impl TextEdit
impl TextEdit
Sourcepub fn apply_under(&self, doc: &mut Doc, obj: &ObjId) -> Result<(), ActionError>
pub fn apply_under(&self, doc: &mut Doc, obj: &ObjId) -> 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.
Sourcepub fn apply_to(
&self,
doc: &mut Doc,
obj: &ObjId,
current: &str,
) -> Result<(), ActionError>
pub fn apply_to( &self, doc: &mut Doc, obj: &ObjId, current: &str, ) -> Result<(), ActionError>
Self::apply_under when the caller already read current, the
text obj holds now: a large text is not read a second time.
§Errors
Trait Implementations§
Source§impl Action for TextEdit
impl Action for TextEdit
Source§fn apply(&self, doc: &mut Doc) -> Result<(), ActionError>
fn apply(&self, doc: &mut Doc) -> Result<(), ActionError>
A record’s own text, created by the first edit.
Source§fn locus(&self) -> ExecutionLocus
fn locus(&self) -> ExecutionLocus
ExecutionLocus::ClientLocal.Source§fn risk(&self) -> RiskLevel
fn risk(&self) -> RiskLevel
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.Source§fn inverse_before(&self, doc: &AutoCommit) -> Option<Self>where
Self: Sized,
fn inverse_before(&self, doc: &AutoCommit) -> Option<Self>where
Self: Sized,
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 moreSource§fn inverse_encoded(&self, doc: &AutoCommit) -> Option<EncodedAction>
fn inverse_encoded(&self, doc: &AutoCommit) -> Option<EncodedAction>
inverse_before as an encoded action, so the
API can undo through apply after the concrete type has been erased. Read moreSource§fn change_kind(&self) -> ChangeKind
fn change_kind(&self) -> ChangeKind
ActionContext, where a
workspace activity feed reads it. Must be a pure function of self.
Defaults to Content.Source§fn action_kind(&self) -> ActionKind
fn action_kind(&self) -> ActionKind
Source§fn incoming_message(&self) -> bool
fn incoming_message(&self) -> bool
INCOMING_MESSAGE_FACET. Must be a
pure function of self.Source§fn readers(&self) -> Option<Vec<MemberId>>
fn readers(&self) -> Option<Vec<MemberId>>
None when every
member who reads the record reads it. The executor marks its change
with READERS_FACET. Must be a pure function
of self.Source§fn irreversible(&self) -> bool
fn irreversible(&self) -> bool
IRREVERSIBLE_TAG. Must be
a pure function of self.Source§fn compensates(&self) -> bool
fn compensates(&self) -> bool
inverse_encoded may answer one): a device
applying it from an app’s model module, which does not compute undo,
writes no entry another device would check that undo against. Must be
a pure function of self.Source§fn describe(&self, doc: &AutoCommit) -> Option<Described>
fn describe(&self, doc: &AutoCommit) -> Option<Described>
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).Source§fn made(&self, doc: &AutoCommit) -> Option<ActionItem>
fn made(&self, doc: &AutoCommit) -> Option<ActionItem>
doc with its writes as an open
transaction: what history names a change that creates something by
(“Created ‘Spring plans’”), which doc before the value applied could
not name because the item did not exist yet. None when the value
made no item of its own, or names none itself; the executor then keeps
the description it read before the value applied.Source§fn steps(&self, doc: &AutoCommit) -> Option<Vec<(Box<dyn Action>, Vec<u8>)>>
fn steps(&self, doc: &AutoCommit) -> Option<Vec<(Box<dyn Action>, Vec<u8>)>>
None for a value that is one step, as almost every value is. Read from doc before
anything applies.Source§impl<'de> Deserialize<'de> for TextEdit
impl<'de> Deserialize<'de> for TextEdit
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for TextEdit
impl StructuralPartialEq for TextEdit
Auto Trait Implementations§
impl Forget for TextEdit
impl Freeze for TextEdit
impl Move 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§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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> ⓘ
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> ⓘ
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