Struct tarantool::tuple::KeyDef

source ·
pub struct KeyDef { /* private fields */ }

Implementations§

source§

impl KeyDef

source

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)
source

pub fn compare(&self, tuple_a: &Tuple, tuple_b: &Tuple) -> Ordering

Compare tuples using the key definition.

  • tuple_a - first tuple
  • tuple_b - second tuple

Returns:

  • Ordering::Equal if key_fields(tuple_a) == key_fields(tuple_b)
  • Ordering::Less if key_fields(tuple_a) < key_fields(tuple_b)
  • Ordering::Greater if key_fields(tuple_a) > key_fields(tuple_b)
source

pub fn compare_with_key<K>(&self, tuple: &Tuple, key: &K) -> Orderingwhere K: ToTupleBuffer + ?Sized,

Compare tuple with key using the key definition.

  • tuple - tuple
  • key - key with MessagePack array header

Returns:

  • Ordering::Equal if key_fields(tuple) == parts(key)
  • Ordering::Less if key_fields(tuple) < parts(key)
  • Ordering::Greater if key_fields(tuple) > parts(key)

Trait Implementations§

source§

impl Debug for KeyDef

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Drop for KeyDef

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

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> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.