Trait yrs::updates::encoder::Encoder

source ·
pub trait Encoder: Write {
Show 14 methods // Required methods fn to_vec(self) -> Vec<u8> ; fn reset_ds_cur_val(&mut self); fn write_ds_clock(&mut self, clock: u32); fn write_ds_len(&mut self, len: u32); fn write_left_id(&mut self, id: &ID); fn write_right_id(&mut self, id: &ID); fn write_client(&mut self, client: ClientID); fn write_info(&mut self, info: u8); fn write_parent_info(&mut self, is_y_key: bool); fn write_type_ref(&mut self, info: u8); fn write_len(&mut self, len: u32); fn write_any(&mut self, any: &Any); fn write_json(&mut self, any: &Any); fn write_key(&mut self, string: &str);
}
Expand description

Trait used by lib0 encoders. Natively lib0 encoding supports two versions:

  1. 1st version (implemented in Yrs) uses simple optimization techniques like var int encoding.
  2. 2nd version optimizes bigger batches of blocks by using run-length encoding.

Both of these define a common set of operations defined in this trait.

Required Methods§

source

fn to_vec(self) -> Vec<u8>

Consume current encoder and return a binary with all data encoded so far.

source

fn reset_ds_cur_val(&mut self)

Reset the state of currently encoded DeleteSet.

source

fn write_ds_clock(&mut self, clock: u32)

Write a clock value of currently encoded DeleteSet client.

source

fn write_ds_len(&mut self, len: u32)

Write a number of client entries used by currently encoded DeleteSet.

source

fn write_left_id(&mut self, id: &ID)

Write unique identifier of a currently encoded [Block]’s left origin.

source

fn write_right_id(&mut self, id: &ID)

Write unique identifier of a currently encoded [Block]’s right origin.

source

fn write_client(&mut self, client: ClientID)

Write currently encoded client identifier.

source

fn write_info(&mut self, info: u8)

Write currently encoded [Block]’s info flags. These contain information about which fields have been provided and which should be skipped during decoding process as well as a type of block currently encoded.

source

fn write_parent_info(&mut self, is_y_key: bool)

Write info flag about currently encoded [Block]’s parent. Is is another block or root type.

source

fn write_type_ref(&mut self, info: u8)

Writes type ref data of currently encoded [Block]’s parent.

source

fn write_len(&mut self, len: u32)

Write length parameter.

source

fn write_any(&mut self, any: &Any)

Encode JSON-like data type. This is a complex structure which is an extension to JavaScript Object Notation with some extra cases.

source

fn write_json(&mut self, any: &Any)

Encode JSON-like data type as nested JSON string. This is a complex structure which is an extension to JavaScript Object Notation with some extra cases.

source

fn write_key(&mut self, string: &str)

Write a string key.

Object Safety§

This trait is not object safe.

Implementors§