pub struct SnapshotWriter { /* private fields */ }Expand description
Writes a complete snapshot to disk.
Entries are written to a temporary file first, then atomically renamed to the final path. The caller provides an iterator over the entries to write.
Implementations§
Source§impl SnapshotWriter
impl SnapshotWriter
Sourcepub fn create(
path: impl Into<PathBuf>,
shard_id: u16,
) -> Result<Self, FormatError>
pub fn create( path: impl Into<PathBuf>, shard_id: u16, ) -> Result<Self, FormatError>
Creates a new snapshot writer. The file won’t appear at path
until Self::finish is called successfully.
Sourcepub fn write_entry(&mut self, entry: &SnapEntry) -> Result<(), FormatError>
pub fn write_entry(&mut self, entry: &SnapEntry) -> Result<(), FormatError>
Writes a single entry to the snapshot.
When encrypted, each entry is written as [nonce: 12B][len: 4B][ciphertext].
The footer CRC covers the encrypted bytes (nonce + len + ciphertext).
Sourcepub fn finish(self) -> Result<(), FormatError>
pub fn finish(self) -> Result<(), FormatError>
Finalizes the snapshot: writes the footer CRC, flushes, and atomically renames the temp file to the final path.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SnapshotWriter
impl RefUnwindSafe for SnapshotWriter
impl Send for SnapshotWriter
impl Sync for SnapshotWriter
impl Unpin for SnapshotWriter
impl UnsafeUnpin for SnapshotWriter
impl UnwindSafe for SnapshotWriter
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