[][src]Trait tari_storage::lmdb_store::FromLmdbBytes

pub trait FromLmdbBytes {
    fn from_lmdb_bytes(&[u8]) -> Result<&Self, String>;
}

Inverts AsLmdbBytes, producing a reference to a structure inside a byte array.

Blanket implementations are provided for LmdbRaw and slices of LmdbRaw things.

This is not a general-purpose deserialisation mechanism. There is no way to use this trait to read values in any format other than how they are natively represented in memory. The only control is that outright invalid values can be rejected so as to avoid undefined behaviour from, eg, constructing &strs with malformed content. Reading values not in native format requires extracting the byte slice and using a separate deserialisation mechanism.

Required methods

fn from_lmdb_bytes(&[u8]) -> Result<&Self, String>

Given a byte slice, return an instance of Self described, or Err with an error message if the given byte slice is not an appropriate value.

Loading content...

Implementations on Foreign Types

impl FromLmdbBytes for str[src]

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

impl FromLmdbBytes for CStr[src]

fn from_lmdb_bytes(bytes: &[u8]) -> Result<&CStr, String>[src]

Directly converts the byte slice into a CStr, including a required trailing NUL.

impl FromLmdbBytes for Ignore[src]

Loading content...

Implementors

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

Loading content...