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§
Sourcefn load(&mut self, state_bytes: &[u8]) -> Result<()>
fn load(&mut self, state_bytes: &[u8]) -> Result<()>
Load the initial fold state. This will be called if the state exists.
Sourcefn accumulate(&mut self, entry: &[u8]) -> Result<()>
fn accumulate(&mut self, entry: &[u8]) -> Result<()>
Process a log entry. Update self state in place.
Sourcefn as_any(&self) -> &dyn Any
fn as_any(&self) -> &dyn Any
Downcast. Useful to access internal state without serialization cost.
Sourcefn clone_boxed(&self) -> Box<dyn Fold>
fn clone_boxed(&self) -> Box<dyn Fold>
Clone the state.