pub struct DeltaChain { /* private fields */ }Expand description
A chain of deltas applied to a base block.
Invariant: deltas.len() <= max_chain_len.
Implementations§
Source§impl DeltaChain
impl DeltaChain
Sourcepub fn new(base_data: Vec<f32>, max_chain_len: u8) -> Self
pub fn new(base_data: Vec<f32>, max_chain_len: u8) -> Self
Create a new chain with a base block.
Sourcepub fn append(&mut self, delta: DeltaRecord) -> Result<(), StoreError>
pub fn append(&mut self, delta: DeltaRecord) -> Result<(), StoreError>
Append a delta. Returns Err(StoreError::DeltaChainTooLong) at max length.
Sourcepub fn reconstruct(&self) -> Vec<f32>
pub fn reconstruct(&self) -> Vec<f32>
Reconstruct the current state by applying all deltas to the base.
Sourcepub fn needs_compaction(&self) -> bool
pub fn needs_compaction(&self) -> bool
Whether the chain needs compaction (at max length).
Sourcepub fn total_bytes(&self) -> usize
pub fn total_bytes(&self) -> usize
Total storage bytes: base + serialized size of all deltas.
Trait Implementations§
Source§impl Clone for DeltaChain
impl Clone for DeltaChain
Source§fn clone(&self) -> DeltaChain
fn clone(&self) -> DeltaChain
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for DeltaChain
impl RefUnwindSafe for DeltaChain
impl Send for DeltaChain
impl Sync for DeltaChain
impl Unpin for DeltaChain
impl UnsafeUnpin for DeltaChain
impl UnwindSafe for DeltaChain
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