Struct Subspace

pub struct Subspace { /* private fields */ }
Expand description

Represents a well-defined region of keyspace in a FoundationDB database

It provides a convenient way to use FoundationDB tuples to define namespaces for different categories of data. The namespace is specified by a prefix tuple which is prepended to all tuples packed by the subspace. When unpacking a key with the subspace, the prefix tuple will be removed from the result.

As a best practice, API clients should use at least one subspace for application data. For general guidance on subspace usage, see the Subspaces section of the Developer Guide.

Implementations§

§

impl Subspace

pub fn all() -> Subspace

all returns the Subspace corresponding to all keys in a FoundationDB database.

pub fn from_bytes(prefix: impl Into<Vec<u8>>) -> Subspace

Returns a new Subspace from the provided bytes.

pub fn into_bytes(self) -> Vec<u8>

Convert into prefix key bytes

pub fn subspace<T>(&self, t: &T) -> Subspace
where T: TuplePack,

Returns a new Subspace whose prefix extends this Subspace with a given tuple encodable.

pub fn bytes(&self) -> &[u8]

bytes returns the literal bytes of the prefix of this Subspace.

pub fn pack<T>(&self, t: &T) -> Vec<u8>
where T: TuplePack,

Returns the key encoding the specified Tuple with the prefix of this Subspace prepended.

pub fn pack_with_versionstamp<T>(&self, t: &T) -> Vec<u8>
where T: TuplePack,

Returns the key encoding the specified Tuple with the prefix of this Subspace prepended, with a versionstamp.

pub fn unpack<'de, T>(&self, key: &'de [u8]) -> Result<T, PackError>
where T: TupleUnpack<'de>,

unpack returns the Tuple encoded by the given key with the prefix of this Subspace removed. unpack will return an error if the key is not in this Subspace or does not encode a well-formed Tuple.

pub fn is_start_of(&self, key: &[u8]) -> bool

is_start_of returns true if the provided key starts with the prefix of this Subspace, indicating that the Subspace logically contains the key.

pub fn range(&self) -> (Vec<u8>, Vec<u8>)

range returns first and last key of given Subspace

Trait Implementations§

§

impl Clone for Subspace

§

fn clone(&self) -> Subspace

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
§

impl Debug for Subspace

§

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

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

impl From<&Subspace> for RangeOption<'static>

Source§

fn from(subspace: &Subspace) -> Self

Converts to this type from the input type.
§

impl<E> From<E> for Subspace
where E: TuplePack,

§

fn from(e: E) -> Subspace

Converts to this type from the input type.
§

impl Hash for Subspace

§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
§

impl PartialEq for Subspace

§

fn eq(&self, other: &Subspace) -> 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.
§

impl Eq for Subspace

§

impl StructuralPartialEq for Subspace

Auto Trait Implementations§

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V