Struct 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 from_bytes(b: impl Into<Bytes>) -> FdbResult<Tuple>

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

Source

pub fn add_null(&mut self)

Append FDB Tuple null value to Tuple.

Source

pub fn add_bytes(&mut self, b: Bytes)

Append Bytes value to the Tuple.

Source

pub fn add_string(&mut self, s: String)

Append String value to the Tuple.

Source

pub fn add_tuple(&mut self, t: Tuple)

Append Tuple value to the Tuple

Source

pub fn add_bigint(&mut self, i: BigInt)

Append BigInt value to the Tuple

§Panic

Panics if the Bytes encoded length of the BigInt is greater than 255.

Source

pub fn add_i64(&mut self, i: i64)

Append i64 value to the Tuple

Source

pub fn add_i32(&mut self, i: i32)

Append i32 value to the Tuple

Source

pub fn add_i16(&mut self, i: i16)

Append i16 value to the Tuple.

Source

pub fn add_i8(&mut self, i: i8)

Append i8 value to the Tuple.

Source

pub fn add_f32(&mut self, f: f32)

Append f32 value to the Tuple.

§Note

The f32 value is encoded using type code 0x20, without any conversion.

Source

pub fn add_f64(&mut self, f: f64)

Append f64 value to the Tuple.

§Note

The f64 value is encoded using type code 0x21, without any conversion.

Source

pub fn add_bool(&mut self, b: bool)

Append bool value to the Tuple.

Source

pub fn add_uuid(&mut self, u: Uuid)

Append Uuid value to the Tuple.

Source

pub fn add_versionstamp(&mut self, v: Versionstamp)

Append Versionstamp value to the Tuple

Source

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

Append elements of Tuple t to Tuple Self

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 get_null(&self, index: usize) -> FdbResult<()>

Gets an indexed item as FDB Tuple null value.

Source

pub fn get_bytes_ref(&self, index: usize) -> FdbResult<&Bytes>

Gets an indexed item as Bytes ref.

Source

pub fn get_string_ref(&self, index: usize) -> FdbResult<&String>

Gets an indexed item as String ref.

Source

pub fn get_tuple_ref(&self, index: usize) -> FdbResult<&Tuple>

Gets an indexed item as Tuple ref.

Source

pub fn get_bigint(&self, index: usize) -> FdbResult<BigInt>

Gets an indexed item as BigInt.

Source

pub fn get_i64(&self, index: usize) -> FdbResult<i64>

Gets an indexed item as i64.

Source

pub fn get_i32(&self, index: usize) -> FdbResult<i32>

Gets an indexed item as i32.

Source

pub fn get_i16(&self, index: usize) -> FdbResult<i16>

Gets an indexed item as i16.

Source

pub fn get_i8(&self, index: usize) -> FdbResult<i8>

Gets an indexed item as i8.

Source

pub fn get_f32(&self, index: usize) -> FdbResult<f32>

Gets an indexed item as f32.

Source

pub fn get_f64(&self, index: usize) -> FdbResult<f64>

Gets an indexed item as f64.

Source

pub fn get_bool(&self, index: usize) -> FdbResult<bool>

Gets an indexed item as bool.

Source

pub fn get_uuid_ref(&self, index: usize) -> FdbResult<&Uuid>

Gets an indexed item as Uuid ref.

Source

pub fn get_versionstamp_ref(&self, index: usize) -> FdbResult<&Versionstamp>

Gets an indexed item as Versionstamp ref.

Source

pub fn is_empty(&self) -> bool

Determine if this Tuple contains no elements.

Source

pub fn size(&self) -> usize

Gets the number of elements in this 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 duplicate 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) -> Self
where Self: Sized,

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

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

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

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

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

impl PartialEq for Tuple

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd 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

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

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

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Eq for Tuple

Auto Trait Implementations§

§

impl Freeze for Tuple

§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 T
where 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 T
where T: Clone,

Source§

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 T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.