Struct yrs::YDelta

source · []
#[repr(C)]
pub struct YDelta { pub tag: c_char, pub len: c_int, pub insert: *mut YOutput, pub attributes_len: c_int, pub attributes: *mut YDeltaAttr, }
Expand description

A data type representing a single change detected over an observed YText/YXmlText. A type of change can be detected using a tag field:

  1. Y_EVENT_CHANGE_ADD marks a new characters added to a collection. In this case insert field contains a pointer to a list of newly inserted values, while len field informs about their count. Additionally attributes_len nad attributes carry information about optional formatting attributes applied to edited blocks.
  2. Y_EVENT_CHANGE_DELETE marks an existing elements removed from the collection. In this case len field informs about number of removed elements.
  3. Y_EVENT_CHANGE_RETAIN marks a number of characters that have not been changed, counted from the previous element. len field informs about number of retained elements. Additionally attributes_len nad attributes carry information about optional formatting attributes applied to edited blocks.

A list of changes returned by ytext_event_delta/yxmltext_event_delta enables to locate a position of all changes within an observed collection by using a combination of added/deleted change structs separated by retained changes (marking eg. number of elements that can be safely skipped, since they remained unchanged).

Fields

tag: c_char

Tag field used to identify particular type of change made:

  1. Y_EVENT_CHANGE_ADD marks a new elements added to a collection. In this case values field contains a pointer to a list of newly inserted values, while len field informs about their count.
  2. Y_EVENT_CHANGE_DELETE marks an existing elements removed from the collection. In this case len field informs about number of removed elements.
  3. Y_EVENT_CHANGE_RETAIN marks a number of elements that have not been changed, counted from the previous element. len field informs about number of retained elements.
len: c_int

Number of element affected by current type of a change. It can refer to a number of inserted values, number of deleted element or a number of retained (unchanged) values.

insert: *mut YOutput

Used in case when current change is of Y_EVENT_CHANGE_ADD type. Contains a list (of length stored in len field) of newly inserted values.

attributes_len: c_int

A number of formatting attributes assigned to an edited area represented by this delta.

attributes: *mut YDeltaAttr

A nullable pointer to a list of formatting attributes assigned to an edited area represented by this delta.

Trait Implementations

Executes the destructor for this type. Read more

Converts to this type from the input type.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.