Skip to main content

Key

Trait Key 

Source
pub trait Key:
    Copy
    + Send
    + Sync {
    const KEY_SCHEME: KeyScheme;
    const GROUP_BITS: u32 = 0;

    // Required methods
    fn as_bytes(&self) -> &[u8] ;
    fn as_bytes_mut(&mut self) -> &mut [u8] ;
    fn from_bytes(bytes: &[u8]) -> Self;
    fn zeroed() -> Self;
}
Expand description

Key metadata trait — describes key encoding for armdb collections.

Analogous to Cid in the armour crate, but without encode/decode methods. Only carries compile-time constants for TreeMeta construction.

Implementations must guarantee that the type is safe to transmute to/from [u8; size_of::<Self>()] — all bit patterns valid, no padding. Use [impl_key_zerocopy!] for zerocopy types or [impl_key_bytemuck!] for bytemuck types to get correct implementations.

§Example

use armdb::{Key, impl_key_zerocopy};
use armour_core::{KeyScheme, KeyType};

impl_key_zerocopy!(UserId, KeyScheme::Typed(&[KeyType::Fuid]));

Required Associated Constants§

Source

const KEY_SCHEME: KeyScheme

Key encoding scheme.

Provided Associated Constants§

Source

const GROUP_BITS: u32 = 0

Bits used for group_id / shard routing.

Required Methods§

Source

fn as_bytes(&self) -> &[u8]

Source

fn as_bytes_mut(&mut self) -> &mut [u8]

Source

fn from_bytes(bytes: &[u8]) -> Self

Source

fn zeroed() -> Self

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Key for u64_be

Source§

const KEY_SCHEME: KeyScheme

Source§

fn as_bytes(&self) -> &[u8]

Source§

fn as_bytes_mut(&mut self) -> &mut [u8]

Source§

fn from_bytes(bytes: &[u8]) -> Self

Source§

fn zeroed() -> Self

Source§

impl<H: Send + Sync> Key for Fuid<H>

Source§

const KEY_SCHEME: KeyScheme

Source§

fn as_bytes(&self) -> &[u8]

Source§

fn as_bytes_mut(&mut self) -> &mut [u8]

Source§

fn from_bytes(bytes: &[u8]) -> Self

Source§

fn zeroed() -> Self

Source§

impl<T: Send + Sync> Key for Id64<T>

Source§

const KEY_SCHEME: KeyScheme

Source§

fn as_bytes(&self) -> &[u8]

Source§

fn as_bytes_mut(&mut self) -> &mut [u8]

Source§

fn from_bytes(bytes: &[u8]) -> Self

Source§

fn zeroed() -> Self

Source§

impl<const N: usize> Key for [u8; N]

Source§

const KEY_SCHEME: KeyScheme

Source§

fn as_bytes(&self) -> &[u8]

Source§

fn as_bytes_mut(&mut self) -> &mut [u8]

Source§

fn from_bytes(bytes: &[u8]) -> Self

Source§

fn zeroed() -> Self

Implementors§