Trait FromLmdbBytes

Source
pub trait FromLmdbBytes {
    // Required method
    fn from_lmdb_bytes(_: &[u8]) -> Result<&Self, String>;
}
Expand description

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§

Source

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.

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 FromLmdbBytes for str

Source§

impl FromLmdbBytes for CStr

Source§

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

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

Source§

impl<V: LmdbRaw> FromLmdbBytes for [V]

Source§

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

Implementors§