pub trait EntityBinding<E> {
// Required methods
fn entry_to_object(
&self,
key: &DatabaseEntry,
data: &DatabaseEntry,
) -> Result<E>;
fn object_to_key(&self, object: &E, key: &mut DatabaseEntry) -> Result<()>;
fn object_to_data(&self, object: &E, data: &mut DatabaseEntry) -> Result<()>;
}Expand description
Converts between key+data entries and an entity object.
This trait is used for entity bindings where the key and data are stored separately but represent a single logical entity.
Required Methods§
Sourcefn entry_to_object(
&self,
key: &DatabaseEntry,
data: &DatabaseEntry,
) -> Result<E>
fn entry_to_object( &self, key: &DatabaseEntry, data: &DatabaseEntry, ) -> Result<E>
Converts key and data entries to an entity object.
§Errors
Returns BindError if the entries cannot be deserialized.
Sourcefn object_to_key(&self, object: &E, key: &mut DatabaseEntry) -> Result<()>
fn object_to_key(&self, object: &E, key: &mut DatabaseEntry) -> Result<()>
Extracts the key from an entity object and writes it to a DatabaseEntry.
§Errors
Returns BindError if the key cannot be serialized.
Sourcefn object_to_data(&self, object: &E, data: &mut DatabaseEntry) -> Result<()>
fn object_to_data(&self, object: &E, data: &mut DatabaseEntry) -> Result<()>
Extracts the data from an entity object and writes it to a DatabaseEntry.
§Errors
Returns BindError if the data cannot be serialized.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".