Skip to main content

Decoder

Trait Decoder 

Source
pub trait Decoder: Read {
Show 14 methods // Required methods fn reset_ds_cur_val(&mut self); fn read_ds_clock(&mut self) -> Result<u32, Error>; fn read_ds_len(&mut self) -> Result<u32, Error>; fn read_left_id(&mut self) -> Result<ID, Error>; fn read_right_id(&mut self) -> Result<ID, Error>; fn read_client(&mut self) -> Result<u64, Error>; fn read_info(&mut self) -> Result<u8, Error>; fn read_parent_info(&mut self) -> Result<bool, Error>; fn read_type_ref(&mut self) -> Result<u8, Error>; fn read_len(&mut self) -> Result<u32, Error>; fn read_any(&mut self) -> Result<Any, Error>; fn read_json(&mut self) -> Result<Any, Error>; fn read_key(&mut self) -> Result<Arc<str>, Error>; fn read_to_end(&mut self) -> Result<&[u8], Error>;
}
Expand description

Trait used by lib0 decoders. 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 reset_ds_cur_val(&mut self)

Reset the value of current delete set state.

Source

fn read_ds_clock(&mut self) -> Result<u32, Error>

Read next DeleteSet clock value.

Source

fn read_ds_len(&mut self) -> Result<u32, Error>

Read the number of clients stored in encoded DeleteSet.

Source

fn read_left_id(&mut self) -> Result<ID, Error>

Read left origin of a currently decoded [Block].

Source

fn read_right_id(&mut self) -> Result<ID, Error>

Read right origin of a currently decoded [Block].

Source

fn read_client(&mut self) -> Result<u64, Error>

Read currently decoded client identifier.

Source

fn read_info(&mut self) -> Result<u8, Error>

Read info bit flags of a currently decoded [Block].

Source

fn read_parent_info(&mut self) -> Result<bool, Error>

Read bit flags determining type of parent of a currently decoded [Block].

Source

fn read_type_ref(&mut self) -> Result<u8, Error>

Read type ref info of a currently decoded [Block] parent.

Source

fn read_len(&mut self) -> Result<u32, Error>

Read length parameter.

Source

fn read_any(&mut self) -> Result<Any, Error>

Decode a JSON-like data type. It’s a complex type which is an extension of native JavaScript Object Notation.

Source

fn read_json(&mut self) -> Result<Any, Error>

Decode an embedded JSON string into Any struct. It’s a complex type which is an extension of native JavaScript Object Notation.

Source

fn read_key(&mut self) -> Result<Arc<str>, Error>

Read key string.

Source

fn read_to_end(&mut self) -> Result<&[u8], Error>

Consume a rest of the decoded buffer data and return it without parsing.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<'a> Decoder for DecoderV1<'a>

Source§

impl<'a> Decoder for DecoderV2<'a>