Trait Encoder
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: u64);
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:
- 1st version (implemented in Yrs) uses simple optimization techniques like var int encoding.
- 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§
fn to_vec(self) -> Vec<u8> ⓘ
fn to_vec(self) -> Vec<u8> ⓘ
Consume current encoder and return a binary with all data encoded so far.
fn reset_ds_cur_val(&mut self)
fn reset_ds_cur_val(&mut self)
Reset the state of currently encoded DeleteSet.
fn write_ds_clock(&mut self, clock: u32)
fn write_ds_clock(&mut self, clock: u32)
Write a clock value of currently encoded DeleteSet client.
fn write_ds_len(&mut self, len: u32)
fn write_ds_len(&mut self, len: u32)
Write a number of client entries used by currently encoded DeleteSet.
fn write_left_id(&mut self, id: &ID)
fn write_left_id(&mut self, id: &ID)
Write unique identifier of a currently encoded [Block]’s left origin.
fn write_right_id(&mut self, id: &ID)
fn write_right_id(&mut self, id: &ID)
Write unique identifier of a currently encoded [Block]’s right origin.
fn write_client(&mut self, client: u64)
fn write_client(&mut self, client: u64)
Write currently encoded client identifier.
fn write_info(&mut self, info: u8)
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.
fn write_parent_info(&mut self, is_y_key: bool)
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.
fn write_type_ref(&mut self, info: u8)
fn write_type_ref(&mut self, info: u8)
Writes type ref data of currently encoded [Block]’s parent.
fn write_any(&mut self, any: &Any)
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.
fn write_json(&mut self, any: &Any)
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.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.