Struct fdb::tuple::Tuple

source ·
pub struct Tuple { /* private fields */ }
Expand description

Represents a set of elements that make up a sortable, typed key.

Tuple is comparable with other Tuples and will sort in Rust in the same order in which they would sort in FDB. Tuples sort first by the first element, then by the second, etc., This make tuple layer ideal for building a variety of higher-level data models.

For general guidance on tuple usage, see this link.

Tuple can contain Null, Bytes, String, another Tuple, BigInt, i64, i32, i16, i8, f32, f64, bool, Uuid, Versionstamp values.

Implementations§

source§

impl Tuple

source

pub fn new() -> Tuple

Create a new empty Tuple.

source

pub fn get<'a, T>(&'a self, index: usize) -> Option<T>where T: TupleElementGet<'a> + 'a,

Provides the Tuple element at the given index.

If you want to return a FdbResult, use FdbError with TUPLE_GET.

source

pub fn pop_back<T>(&mut self) -> Option<T>where T: TupleElementPop,

Removes the last element from the Tuple and returns it, or None if it is empty.

If there is a value of a different type other than type T, the Tuple is not mutated and None is returned.

source

pub fn pop_front<T>(&mut self) -> Option<T>where T: TupleElementPop,

Removes the first element from the Tuple and returns it, or None if it is empty.

If there is a value of a different type other than type T, the Tuple is not mutated and None is returned.

source

pub fn push_back<T>(&mut self, value: T)where T: TupleElementPush,

Appends a Tuple element.

source

pub fn push_front<T>(&mut self, value: T)where T: TupleElementPush,

Prepends a Tuple element.

source

pub fn append(&mut self, other: &mut Tuple)

Moves all the elements of the Tuple other into Tuple self, leaving the Tuple other empty.

Panics

Panics if the new number of elements in self overflows a usize.

source

pub fn has_incomplete_versionstamp(&self) -> bool

Determines if there is a Versionstamp included in this Tuple that has not had its transaction version set.

source

pub fn is_empty(&self) -> bool

Returns true if the Tuple is empty.

source

pub fn len(&self) -> usize

Returns the number of elements in the Tuple.

source

pub fn pack(&self) -> Bytes

Get an encoded representation of this Tuple.

source

pub fn pack_with_versionstamp(&self, prefix: Bytes) -> FdbResult<Bytes>

Get an encoded representation of this Tuple for use with SetVersionstampedKey.

Panic

The index where incomplete versionstamp is located is a 32-bit little-endian integer. If the generated index overflows u32, then this function panics.

source

pub fn range(&self, prefix: Bytes) -> Range

Returns a range representing all keys that encode Tuples strictly starting with this Tuple.

Panic

Panics if the tuple contains an incomplete Versionstamp.

Trait Implementations§

source§

impl Clone for Tuple

source§

fn clone(&self) -> Tuple

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Tuple

source§

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

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

impl Default for Tuple

source§

fn default() -> Tuple

Returns the “default value” for a type. Read more
source§

impl From<Mapper> for Tuple

source§

fn from(m: Mapper) -> Tuple

Converts to this type from the input type.
source§

impl From<Tuple> for Mapper

source§

fn from(t: Tuple) -> Mapper

Converts to this type from the input type.
source§

impl Ord for Tuple

source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl PartialEq<Tuple> for Tuple

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd<Tuple> for Tuple

source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl TryFrom<Bytes> for Tuple

source§

fn try_from(b: Bytes) -> FdbResult<Tuple>

Construct a new Tuple with elements decoded from a supplied Bytes.

§

type Error = FdbError

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

impl TryFrom<Key> for Tuple

source§

fn try_from(k: Key) -> FdbResult<Tuple>

Construct a new Tuple with elements decoded from a supplied Key.

§

type Error = FdbError

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

impl TryFrom<Value> for Tuple

source§

fn try_from(v: Value) -> FdbResult<Tuple>

Construct a new Tuple with elements decoded from a supplied Value.

§

type Error = FdbError

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

impl Eq for Tuple

source§

impl<'a> TupleElementGet<'a> for &'a Tuple

source§

impl TupleElementPop for Tuple

source§

impl TupleElementPush for Tuple

Auto Trait Implementations§

§

impl RefUnwindSafe for Tuple

§

impl Send for Tuple

§

impl Sync for Tuple

§

impl Unpin for Tuple

§

impl UnwindSafe for Tuple

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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.