Skip to main content

CatalogEntry

Struct CatalogEntry 

Source
pub struct CatalogEntry<'a> {
    pub model: u8,
    pub value_type: u8,
    pub band: u8,
    pub p_exp: u8,
    pub shape_tag: [u8; 16],
    pub root_addr: u64,
    pub element_count: u64,
    pub bytes: u64,
    pub db: u16,
    pub next: u64,
    pub name: &'a [u8],
    pub schema: &'a [u8],
}
Expand description

One catalogue entry, decoded, borrowing its name and schema from the file.

Fields§

§model: u8

Raw model byte. Ask CatalogEntry::model what it means.

§value_type: u8

Raw value type byte, zero unless the model is kv.

§band: u8

Raw band byte.

§p_exp: u8

Partition count as a base two exponent. Never 1: a two way split buys nothing and costs an indirection, so the ladder goes one, four, sixteen.

§shape_tag: [u8; 16]

The 128 bit shape hash, or all zeroes for a collection that RESP created and that therefore has no declared shape.

§root_addr: u64

Where the collection’s root lives.

§element_count: u64

Elements, for SCARD and friends without walking anything.

§bytes: u64

Bytes the collection occupies.

§db: u16

Which logical database.

§next: u64

The next entry in the chain, or 0.

§name: &'a [u8]

The collection’s name.

§schema: &'a [u8]

The canonical shape description the shape_tag hashes, or empty.

Implementations§

Source§

impl<'a> CatalogEntry<'a>

Source

pub const fn new(model: Model, name: &'a [u8]) -> CatalogEntry<'a>

An entry for a named collection with no declared shape.

Source

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

Writes the entry and its checksum, returning the length written.

Unlike a log record this one writes its len up front, because a catalogue entry is not appended to a log that a reader is scanning. It is written to a free segment and then reached by a pointer that is published in the next superblock flip, so the entry is either reachable and whole or not reachable at all.

§Errors

Code::Invalid for an oversized name or an illegal p_exp, Code::Full if buf is too small.

Source

pub fn decode(bytes: &'a [u8]) -> Result<CatalogEntry<'a>>

Reads the entry at the front of bytes.

§Errors

Code::Corrupt if the length is impossible, if the entry runs past the end of bytes, if the name and schema do not fit inside it, or if the checksum fails.

Source

pub fn model(&self) -> Option<Model>

The model, if this version knows it.

Source

pub fn value_type(&self) -> Option<ValueType>

The value type, if the model is kv and this version knows the byte.

Source

pub fn band(&self) -> Option<Band>

The band, if this version knows it.

Source

pub const fn partitions(&self) -> u32

How many partitions the collection is split into.

Source

pub fn is_shape_tagged(&self) -> bool

Whether the collection was declared with a shape.

An all zero tag means it was not, which is the case for anything a RESP client created. Shape checking has nothing to check against there and says so rather than inventing a shape.

Trait Implementations§

Source§

impl<'a> Clone for CatalogEntry<'a>

Source§

fn clone(&self) -> CatalogEntry<'a>

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<'a> Copy for CatalogEntry<'a>

Source§

impl<'a> Debug for CatalogEntry<'a>

Source§

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

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

impl<'a> Eq for CatalogEntry<'a>

Source§

impl<'a> PartialEq for CatalogEntry<'a>

Source§

fn eq(&self, other: &CatalogEntry<'a>) -> bool

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

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

Inequality operator !=. Read more
Source§

impl<'a> StructuralPartialEq for CatalogEntry<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for CatalogEntry<'a>

§

impl<'a> RefUnwindSafe for CatalogEntry<'a>

§

impl<'a> Send for CatalogEntry<'a>

§

impl<'a> Sync for CatalogEntry<'a>

§

impl<'a> Unpin for CatalogEntry<'a>

§

impl<'a> UnsafeUnpin for CatalogEntry<'a>

§

impl<'a> UnwindSafe for CatalogEntry<'a>

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, <T as TryFrom<U>>::Error>

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.