Skip to main content

RecordHeader

Struct RecordHeader 

Source
pub struct RecordHeader {
    pub kind: u8,
    pub flags: u8,
    pub prev: u64,
    pub ttl_ms: u64,
}
Expand description

A record about to be written.

Fields§

§kind: u8

What the value is. A raw byte rather than a RecordKind so that a future version can be written by a build that predates it, which is not as strange as it sounds: compaction copies records it does not interpret.

§flags: u8§prev: u64

The previous address in this key’s chain, or 0.

§ttl_ms: u64

Unix milliseconds, meaningful only when record_flags::HAS_TTL is set.

Implementations§

Source§

impl RecordHeader

Source

pub const fn new(kind: RecordKind) -> RecordHeader

A header for a live value with no TTL, checksummed.

Source

pub const fn with_ttl(self, unix_ms: u64) -> RecordHeader

Sets the TTL and the flag that says it is there.

Source

pub const fn after(self, prev: u64) -> RecordHeader

Chains this record to the previous version of the same key.

Source

pub fn fill(&self, buf: &mut [u8], key: &[u8], value: &[u8]) -> Result<usize>

Writes everything except len, and returns the exact record length.

The first four bytes are left untouched, which is the point. 06 section 3 requires len to be stored last with a release store, so that a reader either sees a whole record or sees a zero and stops. Writing it here would put a length in front of a body that is not there yet, and a crash in between produces a record that claims bytes it does not have.

The caller finishes with seal_len, which is the release store’s payload. Ordering is the caller’s job because this crate does not know what memory the buffer is in.

§Errors

Code::Invalid for an oversized key, Code::Full if buf is too small for the record.

Trait Implementations§

Source§

impl Clone for RecordHeader

Source§

fn clone(&self) -> RecordHeader

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 Copy for RecordHeader

Source§

impl Debug for RecordHeader

Source§

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

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

impl Eq for RecordHeader

Source§

impl PartialEq for RecordHeader

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for RecordHeader

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, 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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.