Expand description
§raft-wal
A minimal append-only WAL (Write-Ahead Log) optimized for Raft consensus.
- Segment-based storage — log is split into segment files;
compact()deletes old segments without rewriting. - CRC32C checksums — HW-accelerated integrity checks on every entry.
- Raft-correct durability — metadata (term/vote) is always fsynced;
log entries are buffered with opt-in
RaftWal::sync. - Parallel recovery — segments are read and verified concurrently.
- openraft integration — enable
openraft-storagefeature forRaftLogStorageimplementation.
§Usage
use raft_wal::RaftWal;
let mut wal = RaftWal::open(dir.path()).unwrap();
wal.append(1, b"entry-1").unwrap();
wal.append(2, b"entry-2").unwrap();
let entries: Vec<_> = wal.iter().collect();
assert_eq!(entries.len(), 2);
wal.set_meta("vote", b"node-1").unwrap();
assert_eq!(wal.get_meta("vote"), Some(b"node-1".as_slice()));Modules§
- crc
- CRC32C functions (hw-accelerated with
std, software fallback inno_std). CRC32C abstraction — hardware-accelerated whenstdfeature is enabled, software lookup table fallback forno_std. - impls
- Optional trait implementations for Raft framework integration.
- wire
- Wire format serialization and parsing (no_std compatible). Wire format serialization and parsing (no_std compatible).
Structs§
- Entry
- A borrowed entry yielded by iterators over WAL entries.
- Generic
Raft Wal - A generic append-only WAL optimized for Raft, parameterized over the storage backend.
- StdStorage
- A
WalStoragebackend that maps file names to a directory on the local filesystem.
Enums§
- WalError
- Errors returned by WAL operations.
Traits§
- WalStorage
- Trait abstracting file-like I/O for the WAL.