[][src]Trait tari_storage::lmdb_store::AsLmdbBytes

pub trait AsLmdbBytes {
    fn as_lmdb_bytes(&self) -> &[u8];
}

Translates a value into a byte slice to be stored in LMDB.

This is similar to AsRef<[u8]>, but is separate since there are things one may wish to store in LMDB but not have implicitly coerce to &[u8] in other contexts.

Blanket impls are provided for LmdbRaw and for slices of LmdbRaw values. Ideally there'd be one for anything AsRef<[u8]>, but in Rust 1.10 that's not possible due to coherence rules barring having blanket implementations for both LmdbRaw and AsRef<[u8]>, so currently it is provided only for &str and &Vec<u8>.

This is not a general-purpose serialisation mechanism. There is no way to use this trait to store values in a format other than how they are natively represented in memory. Doing this requires serialisation into a byte array before passing it onto lmdb-zero.

Required methods

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

Casts the given reference to a byte slice appropriate for storage in LMDB.

Loading content...

Implementations on Foreign Types

impl<V> AsLmdbBytes for [V] where
    V: LmdbRaw
[src]

impl AsLmdbBytes for [u16][src]

impl AsLmdbBytes for u64[src]

impl AsLmdbBytes for [i64][src]

impl AsLmdbBytes for u32[src]

impl AsLmdbBytes for f64[src]

impl AsLmdbBytes for i32[src]

impl AsLmdbBytes for str[src]

impl AsLmdbBytes for [i16][src]

impl AsLmdbBytes for f32[src]

impl<V> AsLmdbBytes for Vec<V> where
    V: LmdbRaw
[src]

impl AsLmdbBytes for [char][src]

impl AsLmdbBytes for u16[src]

impl AsLmdbBytes for [f32][src]

impl AsLmdbBytes for i16[src]

impl AsLmdbBytes for [u64][src]

impl AsLmdbBytes for [i32][src]

impl AsLmdbBytes for [u32][src]

impl AsLmdbBytes for char[src]

impl AsLmdbBytes for [f64][src]

impl AsLmdbBytes for i64[src]

impl AsLmdbBytes for CStr[src]

fn as_lmdb_bytes(&self) -> &[u8][src]

Returns the raw content of the CStr, including the trailing NUL.

Loading content...

Implementors

impl<V> AsLmdbBytes for V where
    V: LmdbRaw
[src]

Loading content...