pub struct Meta(/* private fields */);Expand description
The meta byte in front of every stored string.
Implementations§
Source§impl Meta
impl Meta
Sourcepub const fn new(kind: Kind, enc: Encoding, has_expiry: bool) -> Meta
pub const fn new(kind: Kind, enc: Encoding, has_expiry: bool) -> Meta
Build the byte for a type, an encoding and the presence of a deadline.
Sourcepub const fn string(enc: Encoding, has_expiry: bool) -> Meta
pub const fn string(enc: Encoding, has_expiry: bool) -> Meta
The byte for a string, which is what everything in strings.rs writes.
Sourcepub const fn slot(kind: Kind, has_expiry: bool) -> Meta
pub const fn slot(kind: Kind, has_expiry: bool) -> Meta
The byte for a value that lives in a slab, with the record holding a number that says where.
The encoding bits are written as zero and mean nothing here. A set’s
encoding is which of the three representations it is in, and that is a
property of the body and not of the record, so OBJECT ENCODING follows
the number and asks. Keeping a copy of it in these two bits would want
the record rewritten every time a set was promoted, for a command nobody
calls in a loop, and two places to disagree about the same fact.
Sourcepub const fn from_byte(b: u8) -> Meta
pub const fn from_byte(b: u8) -> Meta
Read the byte back.
An unknown encoding is impossible from our own writer, so the two spare
bit patterns fall to raw, which is the reading that returns the bytes
unchanged rather than reinterpreting them as something else.
Sourcepub const fn has_expiry(self) -> bool
pub const fn has_expiry(self) -> bool
Whether a deadline follows.
Sourcepub const fn has_access(self) -> bool
pub const fn has_access(self) -> bool
Whether an access field follows the deadline.
Everything this crate writes sets it, so in a running server it is always true and the reader that checks it is checking something that cannot happen. It is here anyway because a bit in the byte costs nothing and the alternative was a flag day: without it, the day the field arrived, every reader had to agree with every writer at exactly the same moment.
It is not a file format concern. These records live in the arena and
never reach a file, and the on disk record in yo_format has its own
layout and its own versioning.
Sourcepub const fn is_cold(self) -> bool
pub const fn is_cold(self) -> bool
Whether the payload is a place on the file rather than the value.
The one question a point read asks before it decides whether it is going to touch a device, and the answer comes out of the byte the lookup has already fetched.
Sourcepub const fn payload_at(self) -> usize
pub const fn payload_at(self) -> usize
Where the payload starts, counting from the meta byte.