pub struct TupleSerdeBinding<K, V> { /* private fields */ }Expand description
Entity binding that uses sort-preserving tuple encoding for keys and serde binary encoding for data.
The key type K must implement SortKey, which guarantees that the
byte-wise order of encoded keys matches the Ord order of the original
values. This makes range scans, get_next, get_prev, and sorted map
operations correct without requiring a custom comparator.
The entity type V is split into a key K and a data payload V via
user-provided extraction functions.
§Examples
ⓘ
use serde::{Serialize, Deserialize};
use noxu_bind::serial::tuple_serde_binding::TupleSerdeBinding;
use noxu_bind::entry_binding::EntityBinding;
use noxu_db::DatabaseEntry;
#[derive(Clone, Serialize, Deserialize, Debug, PartialEq)]
struct Employee {
id: u64,
name: String,
department: String,
}
let binding = TupleSerdeBinding::<u64, Employee>::new(
|emp: &Employee| emp.id,
|key: u64, data: Employee| data,
);Implementations§
Source§impl<K, V> TupleSerdeBinding<K, V>
impl<K, V> TupleSerdeBinding<K, V>
Trait Implementations§
Source§impl<K, V> Debug for TupleSerdeBinding<K, V>
impl<K, V> Debug for TupleSerdeBinding<K, V>
Source§impl<K, V> EntityBinding<V> for TupleSerdeBinding<K, V>
impl<K, V> EntityBinding<V> for TupleSerdeBinding<K, V>
Source§fn entry_to_object(
&self,
key: &DatabaseEntry,
data: &DatabaseEntry,
) -> Result<V>
fn entry_to_object( &self, key: &DatabaseEntry, data: &DatabaseEntry, ) -> Result<V>
Converts key and data entries to an entity object. Read more
Source§fn object_to_key(&self, object: &V, key: &mut DatabaseEntry) -> Result<()>
fn object_to_key(&self, object: &V, key: &mut DatabaseEntry) -> Result<()>
Extracts the key from an entity object and writes it to a
DatabaseEntry. Read moreSource§fn object_to_data(&self, object: &V, data: &mut DatabaseEntry) -> Result<()>
fn object_to_data(&self, object: &V, data: &mut DatabaseEntry) -> Result<()>
Extracts the data from an entity object and writes it to a
DatabaseEntry. Read moreAuto Trait Implementations§
impl<K, V> Freeze for TupleSerdeBinding<K, V>
impl<K, V> !RefUnwindSafe for TupleSerdeBinding<K, V>
impl<K, V> Send for TupleSerdeBinding<K, V>
impl<K, V> Sync for TupleSerdeBinding<K, V>
impl<K, V> Unpin for TupleSerdeBinding<K, V>
impl<K, V> UnsafeUnpin for TupleSerdeBinding<K, V>
impl<K, V> !UnwindSafe for TupleSerdeBinding<K, V>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more