pub struct WalEntry {
pub seq_num: u64,
pub tx_id: u64,
pub op_type: WalOpType,
pub key: Vec<u8>,
pub value: Vec<u8>,
pub timestamp: u64,
pub checksum: u64,
}Expand description
A single decoded entry in the write-ahead log.
Fields§
§seq_num: u64Monotonically increasing sequence number assigned at write time.
tx_id: u64Transaction identifier (0 = no transaction / standalone write).
op_type: WalOpTypeOperation type.
key: Vec<u8>Key bytes (may be empty for Begin/Commit/Rollback/Checkpoint).
value: Vec<u8>Value bytes (may be empty for Delete/Begin/Commit/Rollback/Checkpoint).
timestamp: u64Unix timestamp in nanoseconds captured at write time.
checksum: u64FNV-1a 64-bit checksum of all preceding bytes in the encoded entry.
Implementations§
Source§impl WalEntry
impl WalEntry
Sourcepub fn encode(&self) -> Vec<u8> ⓘ
pub fn encode(&self) -> Vec<u8> ⓘ
Encodes this entry to its wire format.
Layout:
[magic(4)][seq_num(8)][tx_id(8)][op_type(1)][key_len(4)][key(n)]
[value_len(4)][value(m)][timestamp(8)][checksum(8)]
Sourcepub fn decode(data: &[u8], offset: usize) -> Result<(WalEntry, usize), WalError>
pub fn decode(data: &[u8], offset: usize) -> Result<(WalEntry, usize), WalError>
Attempts to decode one entry starting at data[offset..].
Returns (entry, bytes_consumed) on success.
§Errors
WalError::InvalidMagicif the four-byte header does not match.WalError::CorruptedEntryif the buffer is too short or an unknown op-type is encountered.WalError::ChecksumMismatchif the stored checksum disagrees.
Trait Implementations§
impl Eq for WalEntry
impl StructuralPartialEq for WalEntry
Auto Trait Implementations§
impl Freeze for WalEntry
impl RefUnwindSafe for WalEntry
impl Send for WalEntry
impl Sync for WalEntry
impl Unpin for WalEntry
impl UnsafeUnpin for WalEntry
impl UnwindSafe for WalEntry
Blanket Implementations§
impl<T> Allocation for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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>
Converts
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>
Converts
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 more