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
impl SimpleDirectDeltaEncoding
pub fn new(data: &[IndexedData]) -> SimpleDirectDeltaEncoding
pub fn load(data: &[IndexedData], crc: Vec<u8>) -> SimpleDirectDeltaEncoding
Sourcepub fn get_state(&self) -> Vec<u8> ⓘ
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 …)
Sourcepub fn change_index_mapping(&mut self, index: u8, key: &[u8])
pub fn change_index_mapping(&mut self, index: u8, key: &[u8])
Change the index mapping for the given index
Sourcepub fn apply_index_mappings(&mut self)
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.
Sourcepub fn patch(&mut self, new_data: &[IndexedData]) -> Vec<u8> ⓘ
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
pub fn apply_patch( &mut self, diff_data: &[u8], ) -> Result<Vec<IndexedDataResult>, SDDEError>
pub fn fold_bytes(bytes: &[Vec<u8>]) -> Vec<u8> ⓘ
pub fn fold_index_result(bytes: &[IndexedDataResult]) -> Vec<u8> ⓘ
pub fn fold_index(bytes: &[IndexedData]) -> Vec<u8> ⓘ
pub fn get_differences(diff_bytes: &[u8]) -> BTreeMap<u8, EntryDifference>
pub fn get_index_mapping(&self) -> BTreeMap<u8, HistoryValue>
pub fn get_differences_bytes_with_crc(diff_bytes: &[u8]) -> &[u8] ⓘ
Trait Implementations§
Source§impl Clone for SimpleDirectDeltaEncoding
impl Clone for SimpleDirectDeltaEncoding
Source§fn clone(&self) -> SimpleDirectDeltaEncoding
fn clone(&self) -> SimpleDirectDeltaEncoding
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more