pub struct KeyDef { /* private fields */ }
Implementations§
Source§impl KeyDef
impl KeyDef
Sourcepub fn new(items: Vec<KeyDefItem>) -> Self
pub fn new(items: Vec<KeyDefItem>) -> 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: AsTuple,
pub fn compare_with_key<K>(&self, tuple: &Tuple, key: &K) -> Orderingwhere
K: AsTuple,
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 Freeze for KeyDef
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