pub struct ChangesetOffsetWriter { /* private fields */ }std only.Expand description
Writer for appending changeset offsets to a sidecar file.
Implementations§
Source§impl ChangesetOffsetWriter
impl ChangesetOffsetWriter
Sourcepub fn new(path: impl AsRef<Path>, committed_len: u64) -> Result<Self>
pub fn new(path: impl AsRef<Path>, committed_len: u64) -> Result<Self>
Opens or creates the changeset offset file for appending.
The file is healed to match committed_len (from the segment header):
- Partial records (from crash mid-write) are truncated to record boundary
- Extra complete records (from crash after sidecar sync but before header commit) are truncated to match the committed length
- If the file has fewer records than committed, returns an error (data corruption)
This mirrors NippyJar’s healing behavior where config/header is the commit boundary.
Sourcepub fn append(&mut self, offset: &ChangesetOffset) -> Result<()>
pub fn append(&mut self, offset: &ChangesetOffset) -> Result<()>
Appends a single changeset offset record.
Sourcepub fn append_many(&mut self, offsets: &[ChangesetOffset]) -> Result<()>
pub fn append_many(&mut self, offsets: &[ChangesetOffset]) -> Result<()>
Appends multiple changeset offset records.
Sourcepub fn sync(&mut self) -> Result<()>
pub fn sync(&mut self) -> Result<()>
Syncs all data to disk. Must be called before committing the header.
Sourcepub fn truncate(&mut self, len: u64) -> Result<()>
pub fn truncate(&mut self, len: u64) -> Result<()>
Truncates the file to contain exactly len records and syncs to disk.
Used after prune operations to reclaim space.
The sync is required for crash safety - without it, a crash could resurrect the old file length.
Sourcepub const fn truncate_deferred(&mut self, len: u64)
pub const fn truncate_deferred(&mut self, len: u64)
Drops records like Self::truncate, but leaves them on disk until
Self::apply_pending_truncation.
Sourcepub fn apply_pending_truncation(&mut self) -> Result<bool>
pub fn apply_pending_truncation(&mut self) -> Result<bool>
Truncates the file to the records kept by Self::truncate_deferred.
Returns false if no truncation was pending.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ChangesetOffsetWriter
impl RefUnwindSafe for ChangesetOffsetWriter
impl Send for ChangesetOffsetWriter
impl Sync for ChangesetOffsetWriter
impl Unpin for ChangesetOffsetWriter
impl UnsafeUnpin for ChangesetOffsetWriter
impl UnwindSafe for ChangesetOffsetWriter
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreimpl<T> MaybeDebug for Twhere
T: Debug,
§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
§fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 32 bytes