Skip to main content

KeyMeta

Struct KeyMeta 

Source
pub struct KeyMeta {
    pub rtype: RedisType,
    pub flags: u8,
    pub expire_at: u64,
    pub version: u64,
    pub size: u64,
}
Expand description

Fundamental 26-byte metadata structure (aligned with Apache Kvrocks KeyMetadata). 基础通用 26 字节元数据结构(对标 Apache Kvrocks KeyMetadata)

Fields§

§rtype: RedisType§flags: u8§expire_at: u64§version: u64§size: u64

Implementations§

Source§

impl KeyMeta

Source

pub const META_64BIT_ENCODING_MASK: u8 = 0x80

Source

pub const META_TYPE_MASK: u8 = 0x0F

Source

pub const ENCODED_SIZE: usize = 26

Source

pub const KVROCKS_COMPLEX_ENCODED_SIZE: usize = 25

Source

pub const KVROCKS_SINGLE_KV_ENCODED_SIZE: usize = 9

Source

pub const fn new( rtype: RedisType, expire_at: u64, version: u64, size: u64, ) -> Self

Source

pub fn new_with_version(rtype: RedisType, expire_at: u64, size: u64) -> Self

Source

pub const fn is_expired(&self, now_ms: u64) -> bool

Source

pub const fn is_single_kv_type(&self) -> bool

Source

pub const fn is_emptyable_type(&self) -> bool

Source

pub const fn ttl(&self, now_ms: u64) -> i64

Source

pub const fn ttl_ms(&self, now_ms: u64) -> i64

Source

pub const fn ttl_sec(&self, now_ms: u64) -> i64

Source

pub fn expire_at_ms_to_sec(ms: u64) -> u64

Source

pub const fn is_64bit_encoded_flags(flags: u8) -> bool

Source

pub const fn is_64bit_encoded(&self) -> bool

Source

pub const fn common_encoded_size(&self) -> usize

Source

pub const fn get_offset_after_expire(flags: u8) -> usize

Returns byte offset following expiration timestamp in encoded metadata. 获取元数据过期时间之后的字节偏移量(对标 Kvrocks Metadata::GetOffsetAfterExpire)

Source

pub const fn get_offset_after_size(flags: u8) -> usize

Returns byte offset following size field in encoded metadata. 获取复合元数据大小之后的字节偏移量(对标 Kvrocks Metadata::GetOffsetAfterSize)

Source

pub fn encode(&self) -> [u8; 26]

Encodes into standard 26-byte metadata header. 编码为标准 26 字节元数据头

Source

pub fn encode_kvrocks(&self) -> Vec<u8>

Encodes into compact Kvrocks binary format (25-byte composite / 9-byte SingleKV). 编码为 Kvrocks 1:1 紧凑二进制格式(25字节复合类型 / 9字节SingleKV)

Source

pub fn decode(bytes: &[u8]) -> Option<Self>

Decodes metadata header from binary slice. 解码元数据头(支持标准 26 字节头、25 字节复合结构头与 9 字节 SingleKV 头)

Trait Implementations§

Source§

impl Clone for KeyMeta

Source§

fn clone(&self) -> KeyMeta

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 KeyMeta

Source§

impl Debug for KeyMeta

Source§

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

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

impl<'__de> Decode<'__de> for KeyMeta
where '__de:,

Source§

impl Encode for KeyMeta

Source§

impl Eq for KeyMeta

Source§

impl PartialEq for KeyMeta

Source§

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

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> DecodeOwned for T
where T: for<'de> Decode<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.