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§
Sourcefn 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 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.
Sourcefn 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 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
Sourcefn get_entries(&self, range: RangeInclusive<u64>) -> Result<Vec<Entry>, Error>
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.
Sourcefn 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 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
Sourcefn 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 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
fn reset<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Sourcefn last_index(&self) -> u64
fn last_index(&self) -> u64
Get last log index (optimized for frequent access)
§Implementation note
Should maintain cached value updated on write operations