Skip to main content

StateStore

Trait StateStore 

Source
pub trait StateStore: Send + Sync {
    // Required methods
    fn save_checkpoint(&self, checkpoint: &Checkpoint) -> Result<(), StoreError>;
    fn load_latest_checkpoint(&self) -> Result<Option<Checkpoint>, StoreError>;
    fn load_checkpoint(&self, id: u64) -> Result<Option<Checkpoint>, StoreError>;
    fn list_checkpoints(&self) -> Result<Vec<u64>, StoreError>;
    fn prune_checkpoints(&self, keep: usize) -> Result<usize, StoreError>;
    fn put(&self, key: &str, value: &[u8]) -> Result<(), StoreError>;
    fn get(&self, key: &str) -> Result<Option<Vec<u8>>, StoreError>;
    fn delete(&self, key: &str) -> Result<(), StoreError>;
    fn flush(&self) -> Result<(), StoreError>;
}
Expand description

Trait for state storage backends

Required Methods§

Source

fn save_checkpoint(&self, checkpoint: &Checkpoint) -> Result<(), StoreError>

Store a checkpoint

Source

fn load_latest_checkpoint(&self) -> Result<Option<Checkpoint>, StoreError>

Load the latest checkpoint

Source

fn load_checkpoint(&self, id: u64) -> Result<Option<Checkpoint>, StoreError>

Load a specific checkpoint by ID

Source

fn list_checkpoints(&self) -> Result<Vec<u64>, StoreError>

List all checkpoint IDs

Source

fn prune_checkpoints(&self, keep: usize) -> Result<usize, StoreError>

Delete old checkpoints, keeping only the most recent N

Source

fn put(&self, key: &str, value: &[u8]) -> Result<(), StoreError>

Store arbitrary key-value data

Source

fn get(&self, key: &str) -> Result<Option<Vec<u8>>, StoreError>

Retrieve arbitrary key-value data

Source

fn delete(&self, key: &str) -> Result<(), StoreError>

Delete a key

Source

fn flush(&self) -> Result<(), StoreError>

Flush all pending writes to disk

Implementors§