Record

Trait Record 

Source
pub trait Record:
    Serialize
    + DeserializeOwned
    + Sized {
    type Key: Into<Vec<u8>>;

    // Required method
    fn key(&self) -> Self::Key;

    // Provided methods
    fn db_name() -> &'static str { ... }
    fn to_binary(&self) -> Result<Vec<u8>, Error> { ... }
    fn from_binary(bytes: &[u8]) -> Result<Self, Error> { ... }
}
Expand description

When a type conforms to this trait it allows it to be stored and retrieved from the database

Required Associated Types§

Required Methods§

Source

fn key(&self) -> Self::Key

Used to determine the key to use to associate with the object in the database

Provided Methods§

Source

fn db_name() -> &'static str

The database name to save a record in. Defaults to ‘default’

Source

fn to_binary(&self) -> Result<Vec<u8>, Error>

Serializes the record to binary

Source

fn from_binary(bytes: &[u8]) -> Result<Self, Error>

Deserializes a record from binary

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.

Implementors§