pub struct MemStore { /* private fields */ }Expand description
An in-memory WalStore backed by a Vec<u8> behind a short lock.
Everything a FileStore does, without touching the filesystem, including
the sparse-file behaviour of zero-filling a gap when a higher offset is
written first. sync is a no-op — memory has no separate
durable tier — so a MemStore is for tests, examples, and benchmarking the
framing path in isolation, not for durability.
§Examples
use wal_db::{MemStore, Wal};
let wal = Wal::with_store(MemStore::new())?;
let lsn = wal.append(b"in memory")?;
assert_eq!(lsn.get(), 0);Implementations§
Source§impl MemStore
impl MemStore
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Create an empty store that has pre-allocated room for capacity bytes,
to avoid reallocations during a known-size workload.
Sourcepub fn from_bytes(bytes: Vec<u8>) -> Self
pub fn from_bytes(bytes: Vec<u8>) -> Self
Create a store preloaded with bytes — for example a log image captured
elsewhere, so Wal::with_store can recover it.
Trait Implementations§
Source§impl WalStore for MemStore
impl WalStore for MemStore
Source§fn write_at(&self, offset: u64, bytes: &[u8]) -> Result<()>
fn write_at(&self, offset: u64, bytes: &[u8]) -> Result<()>
Write
bytes at byte offset, growing the store and zero-filling any
gap if offset is beyond the current end.Auto Trait Implementations§
impl !Freeze for MemStore
impl RefUnwindSafe for MemStore
impl Send for MemStore
impl Sync for MemStore
impl Unpin for MemStore
impl UnsafeUnpin for MemStore
impl UnwindSafe for MemStore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more