Struct SimpleDirectDeltaEncoding

Source
pub struct SimpleDirectDeltaEncoding {
    pub data_collection: BTreeMap<u8, IndexedData>,
    pub crc: Vec<u8>,
    /* private fields */
}

Fields§

§data_collection: BTreeMap<u8, IndexedData>§crc: Vec<u8>

Implementations§

Source§

impl SimpleDirectDeltaEncoding

Source

pub fn new(data: &[IndexedData]) -> SimpleDirectDeltaEncoding

Source

pub fn load(data: &[IndexedData], crc: Vec<u8>) -> SimpleDirectDeltaEncoding

Source

pub fn get_state(&self) -> Vec<u8>

Current state of the data

  • Indexed data and index mappings are stored in bytes
  • The data is always in the same order (indexed data first, index mappings last …)
Source

pub fn change_index_mapping(&mut self, index: u8, key: &[u8])

Change the index mapping for the given index

Source

pub fn apply_index_mappings(&mut self)

Stores all index mappings in the last index mapping collection.

This is useful when the changed index mappings should not be included in the next patch.
After creating or applying a patch this same logic will be applied.

Source

pub fn patch(&mut self, new_data: &[IndexedData]) -> Vec<u8>

Patch the data with the new data and return the diff data

The diff data is a byte array with the following format:
[CRC length, CRC value, Difference 1, Difference 2, …]

  • The CRC length is a single byte that represents the length of the CRC value
  • The CRC value is the hash of the data before patching
  • The Difference is a struct that represents the difference between the old and new data

The Difference is a byte array with the following format: [Action, Range start, Range length, Value] The Action is a single byte that represents the action that should be taken The Range start is a variable length byte array that represents the start index of the range The Range length is a variable length byte array that represents the length of the range The Value is a variable length byte array that represents the value that should be inserted The Value is only present in the Replace and Insert actions

Source

pub fn apply_patch( &mut self, diff_data: &[u8], ) -> Result<Vec<IndexedDataResult>, SDDEError>

Source

pub fn fold_bytes(bytes: &[Vec<u8>]) -> Vec<u8>

Source

pub fn fold_index_result(bytes: &[IndexedDataResult]) -> Vec<u8>

Source

pub fn fold_index(bytes: &[IndexedData]) -> Vec<u8>

Source

pub fn get_differences(diff_bytes: &[u8]) -> BTreeMap<u8, EntryDifference>

Source

pub fn get_index_mapping(&self) -> BTreeMap<u8, HistoryValue>

Source

pub fn get_differences_bytes_with_crc(diff_bytes: &[u8]) -> &[u8]

Trait Implementations§

Source§

impl Clone for SimpleDirectDeltaEncoding

Source§

fn clone(&self) -> SimpleDirectDeltaEncoding

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.