Skip to main content

Meta

Struct Meta 

Source
pub struct Meta(/* private fields */);
Expand description

The meta byte in front of every stored string.

Implementations§

Source§

impl Meta

Source

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.

Source

pub const fn string(enc: Encoding, has_expiry: bool) -> Meta

The byte for a string, which is what everything in strings.rs writes.

Source

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.

Source

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.

Source

pub const fn byte(self) -> u8

The raw byte, as stored.

Source

pub const fn encoding(self) -> Encoding

Which encoding this value carries.

Source

pub const fn kind(self) -> Kind

Which type this key holds.

Source

pub const fn has_expiry(self) -> bool

Whether a deadline follows.

Source

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.

Source

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.

Source

pub const fn with_cold(self) -> Meta

The same byte with the value declared to be on the file.

Source

pub const fn payload_at(self) -> usize

Where the payload starts, counting from the meta byte.

Trait Implementations§

Source§

impl Clone for Meta

Source§

fn clone(&self) -> Meta

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 Meta

Source§

impl Debug for Meta

Source§

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

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

impl Eq for Meta

Source§

impl PartialEq for Meta

Source§

fn eq(&self, other: &Meta) -> 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 Meta

Auto Trait Implementations§

§

impl Freeze for Meta

§

impl RefUnwindSafe for Meta

§

impl Send for Meta

§

impl Sync for Meta

§

impl Unpin for Meta

§

impl UnsafeUnpin for Meta

§

impl UnwindSafe for Meta

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.