Skip to main content

AsDatabaseBytes

Trait AsDatabaseBytes 

Source
pub trait AsDatabaseBytes {
    const FIXED_SIZE: Option<usize> = None;

    // Required method
    fn as_key_bytes(&self) -> Cow<'_, [u8]>;

    // Provided method
    fn as_value_bytes(&self) -> Cow<'_, [u8]> { ... }
}

Provided Associated Constants§

Source

const FIXED_SIZE: Option<usize> = None

Determines whether the values are of fixed size. This will set the DUP_FIXED_SIZE_VALUES for dup tables flag.

Required Methods§

Source

fn as_key_bytes(&self) -> Cow<'_, [u8]>

Returns the byte representation to be used in key encoding. In the default implementation, this will also be used for the value bytes.

Provided Methods§

Source

fn as_value_bytes(&self) -> Cow<'_, [u8]>

Returns the byte representation to be used in value encoding. This is used if the value needs to be sorted differently in a dup table. DUP values use a lexicographic sort order.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl AsDatabaseBytes for str

Source§

fn as_key_bytes(&self) -> Cow<'_, [u8]>

Source§

impl AsDatabaseBytes for u16

Source§

const FIXED_SIZE: Option<usize>

Source§

fn as_key_bytes(&self) -> Cow<'_, [u8]>

Source§

fn as_value_bytes(&self) -> Cow<'_, [u8]>

Source§

impl AsDatabaseBytes for u32

Source§

const FIXED_SIZE: Option<usize>

Source§

fn as_key_bytes(&self) -> Cow<'_, [u8]>

Source§

fn as_value_bytes(&self) -> Cow<'_, [u8]>

Source§

impl AsDatabaseBytes for u64

Source§

const FIXED_SIZE: Option<usize>

Source§

fn as_key_bytes(&self) -> Cow<'_, [u8]>

Source§

fn as_value_bytes(&self) -> Cow<'_, [u8]>

Source§

impl AsDatabaseBytes for ()

Source§

impl AsDatabaseBytes for String

Source§

fn as_key_bytes(&self) -> Cow<'_, [u8]>

Source§

impl AsDatabaseBytes for Vec<u8>

Source§

fn as_key_bytes(&self) -> Cow<'_, [u8]>

Source§

impl AsDatabaseBytes for CStr

Source§

fn as_key_bytes(&self) -> Cow<'_, [u8]>

Implementors§