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 'life0: 'async_trait,
Self: 'async_trait;
fn entry<'life0, 'async_trait>(
&'life0 self,
index: u64,
) -> Pin<Box<dyn Future<Output = Result<Option<Entry>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: '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 'life0: 'async_trait,
Self: 'async_trait;
fn truncate<'life0, 'async_trait>(
&'life0 self,
from_index: u64,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn is_write_durable(&self) -> bool;
fn reset<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn last_index(&self) -> u64;
// Provided methods
fn replace_range<'life0, 'async_trait>(
&'life0 self,
from_index: u64,
new_entries: Vec<Entry>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait { ... }
fn flush(&self) -> Result<(), Error> { ... }
fn flush_async<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait { ... }
fn load_purge_boundary(&self) -> Result<Option<LogId>, Error> { ... }
}Required Methods§
Sourcefn persist_entries<'life0, 'async_trait>(
&'life0 self,
entries: Vec<Entry>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn persist_entries<'life0, 'async_trait>(
&'life0 self,
entries: Vec<Entry>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: '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
'life0: 'async_trait,
Self: 'async_trait,
fn entry<'life0, 'async_trait>(
&'life0 self,
index: u64,
) -> Pin<Box<dyn Future<Output = Result<Option<Entry>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: '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
'life0: 'async_trait,
Self: 'async_trait,
fn purge<'life0, 'async_trait>(
&'life0 self,
cutoff_index: LogId,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: '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
'life0: 'async_trait,
Self: 'async_trait,
fn truncate<'life0, 'async_trait>(
&'life0 self,
from_index: u64,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Truncates log from specified index onward
Sourcefn is_write_durable(&self) -> bool
fn is_write_durable(&self) -> bool
Whether a single persist_entries call is crash-safe without an explicit flush().
Return true if your backend writes are immediately durable (e.g. any backend
with synchronous write-through to stable storage). Return false if durability
requires an explicit flush() call (e.g. RocksDB without sync=true, sled,
file I/O without sync_all).
This value must be accurate. A wrong true causes durable_index to advance
before data is crash-safe, silently breaking Raft’s durability guarantee.
fn reset<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: '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
Provided Methods§
Sourcefn replace_range<'life0, 'async_trait>(
&'life0 self,
from_index: u64,
new_entries: Vec<Entry>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn replace_range<'life0, 'async_trait>(
&'life0 self,
from_index: u64,
new_entries: Vec<Entry>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Atomically truncate from from_index and persist new_entries in one write.
Default implementation calls truncate then persist_entries sequentially
(non-atomic). Override with a single WriteBatch for true crash atomicity.
Sourcefn flush_async<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn flush_async<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Optional: Flush pending writes (use with caution)
Sourcefn load_purge_boundary(&self) -> Result<Option<LogId>, Error>
fn load_purge_boundary(&self) -> Result<Option<LogId>, Error>
Load the purge boundary persisted by the last purge() call.
Returns the LogId (index + term) of the highest entry ever purged,
or None if purge() has never been called. BufferedRaftLog::new()
uses this to restore last_purged_index/term after a restart so that
entry_term(last_purged_index) returns the correct term even though
the entry has been removed from the in-memory log.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".