pub struct CanonicalLog { /* private fields */ }Expand description
The append-only canonical log file.
Implementations§
Source§impl CanonicalLog
impl CanonicalLog
Sourcepub fn open(path: impl AsRef<Path>) -> Result<Self, LogError>
pub fn open(path: impl AsRef<Path>) -> Result<Self, LogError>
Open or create the canonical log at path. File is opened in
read+write+append-friendly mode; existing content is preserved.
On a freshly-created (or pre-existing zero-byte) file, the
8-byte header (MIMR + format version 1 LE) is written and
fsync’d before this returns. On a file that already has bytes,
the first 8 bytes are validated against the expected header and
rejected with LogError::IncompatibleFormat on mismatch —
before any truncation, append, or replay path runs. This
guards against the destructive-truncate footgun where pointing
Store::open at a misrouted path would silently zero the file.
§Errors
LogError::Ioif the file cannot be created or opened.LogError::IncompatibleFormatif the file’s first bytes are not a valid Mimir log header (truncated, wrong magic, or wrong format version).
Trait Implementations§
Source§impl Debug for CanonicalLog
impl Debug for CanonicalLog
Source§impl LogBackend for CanonicalLog
impl LogBackend for CanonicalLog
Source§fn append(&mut self, bytes: &[u8]) -> Result<(), LogError>
fn append(&mut self, bytes: &[u8]) -> Result<(), LogError>
Append
bytes at the current end. No fsync is implied. Read moreSource§fn sync(&mut self) -> Result<(), LogError>
fn sync(&mut self) -> Result<(), LogError>
Fsync the log. Spec § 6 — data + metadata. Read more
Source§fn truncate(&mut self, new_len: u64) -> Result<(), LogError>
fn truncate(&mut self, new_len: u64) -> Result<(), LogError>
Truncate the log to
new_len bytes (and fsync the truncation). Read moreSource§fn read_all(&mut self) -> Result<Vec<u8>, LogError>
fn read_all(&mut self) -> Result<Vec<u8>, LogError>
Read the entire log into a buffer. Read more
Auto Trait Implementations§
impl Freeze for CanonicalLog
impl RefUnwindSafe for CanonicalLog
impl Send for CanonicalLog
impl Sync for CanonicalLog
impl Unpin for CanonicalLog
impl UnsafeUnpin for CanonicalLog
impl UnwindSafe for CanonicalLog
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