pub struct KeyDef { /* private fields */ }
Implementations§
source§impl KeyDef
impl KeyDef
sourcepub fn new<'a>(
parts: impl IntoIterator<Item = &'a KeyDefPart<'a>>
) -> Result<Self>
pub fn new<'a>( parts: impl IntoIterator<Item = &'a KeyDefPart<'a>> ) -> Result<Self>
Create key definition with key fields with passed typed on passed positions. May be used for tuple format creation and/or tuple comparison.
items
- array with key field identifiers and key field types (see FieldType)
sourcepub fn compare(&self, tuple_a: &Tuple, tuple_b: &Tuple) -> Ordering
pub fn compare(&self, tuple_a: &Tuple, tuple_b: &Tuple) -> Ordering
Compare tuples using the key definition.
tuple_a
- first tupletuple_b
- second tuple
Returns:
Ordering::Equal
ifkey_fields(tuple_a) == key_fields(tuple_b)
Ordering::Less
ifkey_fields(tuple_a) < key_fields(tuple_b)
Ordering::Greater
ifkey_fields(tuple_a) > key_fields(tuple_b)
sourcepub fn compare_with_key<K>(&self, tuple: &Tuple, key: &K) -> Orderingwhere
K: ToTupleBuffer + ?Sized,
pub fn compare_with_key<K>(&self, tuple: &Tuple, key: &K) -> Orderingwhere K: ToTupleBuffer + ?Sized,
Compare tuple with key using the key definition.
tuple
- tuplekey
- key with MessagePack array header
Returns:
Ordering::Equal
ifkey_fields(tuple) == parts(key)
Ordering::Less
ifkey_fields(tuple) < parts(key)
Ordering::Greater
ifkey_fields(tuple) > parts(key)
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for KeyDef
impl !Send for KeyDef
impl !Sync for KeyDef
impl Unpin for KeyDef
impl UnwindSafe for KeyDef
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