LogStore

Trait LogStore 

Source
pub trait LogStore:
    Send
    + Sync
    + 'static {
    // Required methods
    fn persist_entries<'life0, 'async_trait>(
        &'life0 self,
        entries: Vec<Entry>,
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn entry<'life0, 'async_trait>(
        &'life0 self,
        index: u64,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Entry>, Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_entries(
        &self,
        range: RangeInclusive<u64>,
    ) -> Result<Vec<Entry>, Error>;
    fn purge<'life0, 'async_trait>(
        &'life0 self,
        cutoff_index: LogId,
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn truncate<'life0, 'async_trait>(
        &'life0 self,
        from_index: u64,
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn reset<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn last_index(&self) -> u64;

    // Provided methods
    fn flush(&self) -> Result<(), Error> { ... }
    fn flush_async<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}

Required Methods§

Source

fn persist_entries<'life0, 'async_trait>( &'life0 self, entries: Vec<Entry>, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Batch persist entries into disk (optimized for sequential writes)

§Performance

Implementations should use batch operations and avoid per-entry synchronization. Expected throughput: >100k ops/sec.

Source

fn entry<'life0, 'async_trait>( &'life0 self, index: u64, ) -> Pin<Box<dyn Future<Output = Result<Option<Entry>, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get single log entry by index

Source

fn get_entries(&self, range: RangeInclusive<u64>) -> Result<Vec<Entry>, Error>

Get entries in range [start, end] (inclusive)

§Performance

Should use efficient range scans. Expected latency: <1ms for 10k entries.

Source

fn purge<'life0, 'async_trait>( &'life0 self, cutoff_index: LogId, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Remove logs up to specified index

Source

fn truncate<'life0, 'async_trait>( &'life0 self, from_index: u64, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Truncates log from specified index onward

Source

fn reset<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn last_index(&self) -> u64

Get last log index (optimized for frequent access)

§Implementation note

Should maintain cached value updated on write operations

Provided Methods§

Source

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

Optional: Flush pending writes (use with caution)

Source

fn flush_async<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Optional: Flush pending writes (use with caution)

Implementors§