pub struct XorDelta {
pub prev_hash: [u8; 32],
pub new_hash: [u8; 32],
pub patch: Vec<u8>,
pub new_len: usize,
}Expand description
XOR delta for state synchronization
Fields§
§prev_hash: [u8; 32]Hash of previous state
new_hash: [u8; 32]Hash of new state
patch: Vec<u8>Run-length encoded XOR patch
new_len: usizeOriginal new state length (needed for applying delta)
Implementations§
Source§impl XorDelta
impl XorDelta
Sourcepub fn apply(&self, state: &[u8]) -> Result<Vec<u8>, DCPError>
pub fn apply(&self, state: &[u8]) -> Result<Vec<u8>, DCPError>
Apply delta to state Returns the new state if successful
Sourcepub fn patch_size(&self) -> usize
pub fn patch_size(&self) -> usize
Get the size of the compressed patch
Sourcepub fn is_sparse(&self, full_state_size: usize) -> bool
pub fn is_sparse(&self, full_state_size: usize) -> bool
Check if this delta represents a sparse change (patch is smaller than the full state)
Sourcepub fn verify_prev_hash(&self, state: &[u8]) -> bool
pub fn verify_prev_hash(&self, state: &[u8]) -> bool
Verify the delta can be applied to a state
Trait Implementations§
impl Eq for XorDelta
impl StructuralPartialEq for XorDelta
Auto Trait Implementations§
impl Freeze for XorDelta
impl RefUnwindSafe for XorDelta
impl Send for XorDelta
impl Sync for XorDelta
impl Unpin for XorDelta
impl UnsafeUnpin for XorDelta
impl UnwindSafe for XorDelta
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more