Skip to main content

encode_diff

Function encode_diff 

Source
pub fn encode_diff(doc: DocId, remove: &[Tok], add: &[Tok]) -> Vec<u8> 
Expand description

Encodes a differential update into a byte vector.

The resulting byte vector is structured as follows:

  • TAG_DIFF (1 byte)
  • doc_id (variable-length u64)
  • remove.len() (variable-length u64)
  • remove tokens (a sequence of variable-length u64 values)
  • add.len() (variable-length u64)
  • add tokens (a sequence of variable-length u64 values)

§Arguments

  • doc - The document ID.
  • remove - A slice of tokens to be removed from the document.
  • add - A slice of tokens to be added to the document.

§Returns

A Vec<u8> containing the encoded differential frame.