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: u8What 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: u8See record_flags.
prev: u64The previous address in this key’s chain, or 0.
ttl_ms: u64Unix milliseconds, meaningful only when record_flags::HAS_TTL is set.
Implementations§
Source§impl RecordHeader
impl RecordHeader
Sourcepub const fn new(kind: RecordKind) -> RecordHeader
pub const fn new(kind: RecordKind) -> RecordHeader
A header for a live value with no TTL, checksummed.
Sourcepub const fn with_ttl(self, unix_ms: u64) -> RecordHeader
pub const fn with_ttl(self, unix_ms: u64) -> RecordHeader
Sets the TTL and the flag that says it is there.
Sourcepub const fn after(self, prev: u64) -> RecordHeader
pub const fn after(self, prev: u64) -> RecordHeader
Chains this record to the previous version of the same key.
Sourcepub fn fill(&self, buf: &mut [u8], key: &[u8], value: &[u8]) -> Result<usize>
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
impl Clone for RecordHeader
Source§fn clone(&self) -> RecordHeader
fn clone(&self) -> RecordHeader
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more