Skip to main content

TextEdit

Enum TextEdit 

Source
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.

Fields

§delete: usize
§insert: String
§

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.

Fields

§text: String

Implementations§

Source§

impl TextEdit

Source

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.

Source

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

As Self::apply_under.

Trait Implementations§

Source§

impl Action for TextEdit

Source§

fn apply(&self, doc: &mut Doc) -> Result<(), ActionError>

A record’s own text, created by the first edit.

Source§

fn locus(&self) -> ExecutionLocus

Where this action prefers to run. Defaults to ExecutionLocus::ClientLocal.
Source§

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.
Source§

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
Source§

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 more
Source§

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.
Source§

fn action_kind(&self) -> ActionKind

What kind of action this value is: whether it only changes the document or also reaches outside it. Must be a pure function of self. An action that records an outside consequence in the document (an outbox entry) is Outside; the default is Undoable.
Source§

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.
Source§

fn readers(&self) -> Option<Vec<MemberId>>

The members who alone read what this value changes, when what it changes says who reads it (a direct conversation); 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

Whether this value loses something Undo cannot bring back, beside the document change Undo reverts (an account’s secret every device forgets). See IRREVERSIBLE_TAG. Must be a pure function of self.
Source§

fn compensates(&self) -> bool

Whether this value’s undo is its own code’s to compute (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>

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).
Source§

fn made(&self, doc: &AutoCommit) -> Option<ActionItem>

The item this value made, read from 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>)>>

The actions this value is, one for each step it takes, when it stands for several: an undo of three steps is three undos of one, newest first. The executor applies each as an action of its own, so every change names the one step it moved, and a peer replays it as that one action. Each is its payload under this value’s type, with the action it decodes to. None for a value that is one step, as almost every value is. Read from doc before anything applies.
Source§

impl Clone for TextEdit

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TextEdit

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for TextEdit

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for TextEdit

Source§

impl PartialEq for TextEdit

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for TextEdit

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for TextEdit

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more