Struct spacetimedb_vm::expr::SourceSet

source ·
pub struct SourceSet<T, const N: usize>(/* private fields */);
Expand description

A SourceProvider backed by an ArrayVec.

Internally, the SourceSet stores an Option<T> for each planned SourceId which are Option::taken out of the set.

Implementations§

source§

impl<T, const N: usize> SourceSet<T, N>

source

pub fn empty() -> Self

Returns an empty source set.

source

pub fn add(&mut self, table: T) -> SourceId

Insert an entry into this SourceSet so it can be used in a query plan, and return a SourceId which can be embedded in that plan.

source

pub fn take(&mut self, id: SourceId) -> Option<T>

Extract the entry referred to by id from this SourceSet, leaving a “gap” in its place.

Subsequent calls to take on the same id will return None.

source

pub fn len(&self) -> usize

Returns the number of slots for MemTables in this set.

Calling self.take_mem_table(...) or self.take_table(...) won’t affect this number.

source

pub fn is_empty(&self) -> bool

Returns whether this set has any slots for MemTables.

Calling self.take_mem_table(...) or self.take_table(...) won’t affect whether the set is empty.

source§

impl<const N: usize> SourceSet<Vec<ProductValue>, N>

source

pub fn add_mem_table(&mut self, table: MemTable) -> SourceExpr

Insert a MemTable into this SourceSet so it can be used in a query plan, and return a SourceExpr which can be embedded in that plan.

source

pub fn take_table(&mut self, source: &SourceExpr) -> Option<Table>

Resolve source to a Table for use in query execution.

If the source is a SourceExpr::DbTable, this simply clones the DbTable and returns it. (DbTable::clone is inexpensive.) In this case, self is not modified.

If the source is a [SourceExpr::MemTable], this behaves like [Self::take_mem_table]. Subsequent calls to take_table or take_mem_table with the same source will fail.

Trait Implementations§

source§

impl<T: Clone, const N: usize> Clone for SourceSet<T, N>

source§

fn clone(&self) -> SourceSet<T, N>

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<T: Debug, const N: usize> Debug for SourceSet<T, N>

source§

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

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

impl<T, const N: usize> From<[T; N]> for SourceSet<T, N>

source§

fn from(sources: [T; N]) -> Self

Converts to this type from the input type.
source§

impl<T, const N: usize> Index<SourceId> for SourceSet<T, N>

§

type Output = Option<T>

The returned type after indexing.
source§

fn index(&self, idx: SourceId) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
source§

impl<T, const N: usize> IndexMut<SourceId> for SourceSet<T, N>

source§

fn index_mut(&mut self, idx: SourceId) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
source§

impl<T: PartialEq, const N: usize> PartialEq for SourceSet<T, N>

source§

fn eq(&self, other: &SourceSet<T, N>) -> 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<'a, T: 'a + IntoIterator<Item = RelValue<'a>>, const N: usize> SourceProvider<'a> for SourceSet<T, N>

§

type Source = T

The type of in-memory tables that this provider uses.
source§

fn take_source(&mut self, id: SourceId) -> Option<T>

Retrieve the Self::Source associated with id, if any. Read more
source§

impl<T: Eq, const N: usize> Eq for SourceSet<T, N>

source§

impl<T, const N: usize> StructuralPartialEq for SourceSet<T, N>

Auto Trait Implementations§

§

impl<T, const N: usize> Freeze for SourceSet<T, N>
where T: Freeze,

§

impl<T, const N: usize> RefUnwindSafe for SourceSet<T, N>
where T: RefUnwindSafe,

§

impl<T, const N: usize> Send for SourceSet<T, N>
where T: Send,

§

impl<T, const N: usize> Sync for SourceSet<T, N>
where T: Sync,

§

impl<T, const N: usize> Unpin for SourceSet<T, N>
where T: Unpin,

§

impl<T, const N: usize> UnwindSafe for SourceSet<T, N>
where T: UnwindSafe,

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where 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 T
where 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 T
where 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.