Skip to main content

Record

Struct Record 

Source
pub struct Record { /* private fields */ }
Expand description

A single record in the event log.

Records are the on-disk representation of events. Each record contains an offset (logical position), a record kind, compression kind, the event payload, and is serialized with a CRC32 checksum for integrity.

§Record Kinds

Implementations§

Source§

impl Record

Source

pub fn new(offset: Offset, prev_hash: Option<ChainHash>, payload: Bytes) -> Self

Creates a new data record with the given offset and payload (uncompressed).

Source

pub fn with_kind( offset: Offset, prev_hash: Option<ChainHash>, kind: RecordKind, payload: Bytes, ) -> Self

Creates a new record with a specific kind (uncompressed).

Source

pub fn with_compression( offset: Offset, prev_hash: Option<ChainHash>, kind: RecordKind, compression: CompressionKind, payload: Bytes, ) -> Self

Creates a new record with a specific kind and compression.

Source

pub fn offset(&self) -> Offset

Returns the offset of this record.

Source

pub fn prev_hash(&self) -> Option<ChainHash>

Returns the hash of the previous record, if any.

Source

pub fn kind(&self) -> RecordKind

Returns the kind of this record.

Source

pub fn compression(&self) -> CompressionKind

Returns the compression kind used for the payload.

Source

pub fn payload(&self) -> &Bytes

Returns the payload of this record.

Source

pub fn is_checkpoint(&self) -> bool

Returns true if this is a checkpoint record.

Source

pub fn compute_hash(&self) -> ChainHash

Computes the hash of this record for chain linking.

The hash covers the kind byte and payload to ensure the record kind is part of the tamper-evident chain. The hash is computed over the original (uncompressed) payload.

Source

pub fn to_bytes(&self) -> Vec<u8>

Serializes the record to bytes.

Format: [offset:u64][prev_hash:32B][kind:u8][compression:u8][length:u32][payload][crc32:u32]

All integers are little-endian.

Source

pub fn to_bytes_into(&self, buf: &mut BytesMut)

Serializes the record into an existing BytesMut buffer (zero-copy path).

Source

pub fn from_bytes(data: &Bytes) -> Result<(Self, usize), StorageError>

Deserializes a record from bytes.

Returns the parsed record and the number of bytes consumed. Uses zero-copy slicing for the payload via Bytes::slice.

AUDIT-2026-03 M-8: Detects torn writes via RECORD_END sentinel check.

§Errors

Trait Implementations§

Source§

impl Clone for Record

Source§

fn clone(&self) -> Record

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Record

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Hash for Record

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Record

Source§

fn eq(&self, other: &Record) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Record

Source§

impl StructuralPartialEq for Record

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more