Skip to main content

Fold

Trait Fold 

Source
pub trait Fold:
    Debug
    + 'static
    + Send
    + Sync {
    // Required methods
    fn load(&mut self, state_bytes: &[u8]) -> Result<()>;
    fn dump(&self) -> Result<Vec<u8>>;
    fn accumulate(&mut self, entry: &[u8]) -> Result<()>;
    fn as_any(&self) -> &dyn Any;
    fn clone_boxed(&self) -> Box<dyn Fold>;
}
Expand description

The actual logic of a “fold” function, and its associated state.

Required Methods§

Source

fn load(&mut self, state_bytes: &[u8]) -> Result<()>

Load the initial fold state. This will be called if the state exists.

Source

fn dump(&self) -> Result<Vec<u8>>

Dump the fold state as bytes.

Source

fn accumulate(&mut self, entry: &[u8]) -> Result<()>

Process a log entry. Update self state in place.

Source

fn as_any(&self) -> &dyn Any

Downcast. Useful to access internal state without serialization cost.

Source

fn clone_boxed(&self) -> Box<dyn Fold>

Clone the state.

Implementors§