DataStore

Trait DataStore 

Source
pub trait DataStore {
    type Output;

    // Required methods
    fn has_data(&self) -> bool;
    fn reset(&mut self);
    fn append(&mut self, data: Value) -> Result<()>;
    fn fetch(
        &mut self,
        count: Option<usize>,
        max_bytes: Option<usize>,
    ) -> Result<Option<DataResult<Self::Output>>>;
    fn remove(&mut self, data: &[Box<dyn Equivalent>]) -> Result<()>;
}
Expand description

A trait for implementing persistent data stores that support batched operations. Provides a common interface for storing, retrieving, and managing data with support for size limits and batch processing.

Required Associated Types§

Source

type Output

The type of data returned by fetch operations.

Required Methods§

Source

fn has_data(&self) -> bool

Checks if the store contains any data that can be fetched.

Source

fn reset(&mut self)

Removes all data from the store and resets it to initial state.

Source

fn append(&mut self, data: Value) -> Result<()>

Appends a new item to the store.

§Arguments
  • data - JSON value to store
Source

fn fetch( &mut self, count: Option<usize>, max_bytes: Option<usize>, ) -> Result<Option<DataResult<Self::Output>>>

Fetches a batch of data from the store, respecting optional count and size limits.

§Arguments
  • count - Optional maximum number of items to fetch
  • max_bytes - Optional maximum total size in bytes to fetch

Returns the fetched data along with items that can be passed to remove().

Source

fn remove(&mut self, data: &[Box<dyn Equivalent>]) -> Result<()>

Removes previously fetched data from the store.

§Arguments
  • data - Slice of removable items from a previous fetch operation

Implementors§