Skip to main content

Kind

Enum Kind 

Source
pub enum Kind {
    String = 0,
    Hash = 1,
    Set = 2,
    Zset = 3,
    List = 4,
    Stream = 5,
    Array = 6,
    Foreign = 7,
}
Expand description

What TYPE calls a key, and what the meta byte’s tag holds.

The numbers are the same numbers yo_format::ValueType uses on disk, so that saving a key is a copy of the tag rather than a translation of it. There is a test at the bottom of this file holding the two in step, and it takes a dev dependency on yo-format for no other reason.

The list is shorter than the on disk one because some of those are the same thing in memory. A bitmap is a string and a HyperLogLog is a string, in Redis as much as here, and TYPE on either answers string. The catalog draws finer lines because a reader wants to know what a blob meant.

Variants§

§

String = 0

A string, and everything Redis stores as one.

§

Hash = 1

A hash.

§

Set = 2

A set.

§

Zset = 3

A sorted set.

§

List = 4

A list.

§

Stream = 5

A stream.

§

Array = 6

A sparse array.

§

Foreign = 7

A body this crate does not know the type of.

The last of the eight patterns the tag can hold, and it is spent on an escape rather than on one more type. Everything below this crate is a primitive that the document, vector and graph engines are built out of, so those engines sit above it and cannot be named here without a cycle, and there are three of them and one pattern. An escape holds all three, and the body says what it is when asked.

It is the one kind with no yo_format::catalog::ValueType beside it, because this version’s writer does not save a foreign body and there is nothing on disk for the catalog to name. When one of them becomes saveable it gets its own number there, which does not have to be this one, since nothing in a file has to agree with a tag that only ever exists in memory.

Implementations§

Source§

impl Kind

Source

pub const fn name(self) -> &'static str

The word TYPE replies with.

A foreign body knows its own word and this does not, so the answer here is the one a caller sees when it has a kind and no body. Go through crate::Keyspace::type_name to get what the client should be told.

Source

pub const fn is_body(self) -> bool

Whether the body lives in a slab rather than in the record.

Everything but a string, which is its own record. The arms that walk a slot ask this rather than listing six kinds, so a new body kind is one arm here and not six lists to find.

Trait Implementations§

Source§

impl Clone for Kind

Source§

fn clone(&self) -> Kind

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 Kind

Source§

impl Debug for Kind

Source§

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

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

impl Eq for Kind

Source§

impl PartialEq for Kind

Source§

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

Auto Trait Implementations§

§

impl Freeze for Kind

§

impl RefUnwindSafe for Kind

§

impl Send for Kind

§

impl Sync for Kind

§

impl Unpin for Kind

§

impl UnsafeUnpin for Kind

§

impl UnwindSafe for Kind

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.