LoadExecutor

Struct LoadExecutor 

Source
pub struct LoadExecutor<E: EntityKind> { /* private fields */ }
Expand description

LoadExecutor

Implementations§

Source§

impl<E: EntityKind> LoadExecutor<E>

Source

pub const fn new(db: Db<E::Canister>, debug: bool) -> Self

Source

pub fn one(&self, value: impl FieldValue) -> Result<Response<E>, Error>

Execute a query for a single primary key.

Source

pub fn only(&self) -> Result<Response<E>, Error>

Execute a query for the unit primary key.

Source

pub fn many<I, V>(&self, values: I) -> Result<Response<E>, Error>
where I: IntoIterator<Item = V>, V: FieldValue,

Execute a query matching multiple primary keys.

Source

pub fn all(&self) -> Result<Response<E>, Error>

Execute an unfiltered query for all rows.

Source

pub fn filter<F, I>(&self, f: F) -> Result<Response<E>, Error>
where F: FnOnce(FilterDsl) -> I, I: IntoFilterExpr,

Execute a query built from a filter.

Source

pub fn require_one(&self, query: LoadQuery) -> Result<(), Error>

Execute a query and require exactly one row.

Source

pub fn require_one_pk(&self, value: impl FieldValue) -> Result<(), Error>

Require exactly one row by primary key.

Source

pub fn require_one_filter<F, I>(&self, f: F) -> Result<(), Error>
where F: FnOnce(FilterDsl) -> I, I: IntoFilterExpr,

Require exactly one row from a filter.

Source

pub fn exists(&self, query: LoadQuery) -> Result<bool, Error>

Check whether at least one row matches the query.

Note: existence checks are best-effort. If matching rows are malformed or missing, exists may return false.

Respects offset/limit when provided (limit=0 returns false).

Source

pub fn exists_one(&self, value: impl FieldValue) -> Result<bool, Error>

Check existence by primary key.

Source

pub fn exists_filter<F, I>(&self, f: F) -> Result<bool, Error>
where F: FnOnce(FilterDsl) -> I, I: IntoFilterExpr,

Check existence with a filter.

Source

pub fn exists_any(&self) -> Result<bool, Error>

Check whether the table contains any rows.

Source

pub fn ensure_exists_one(&self, value: impl FieldValue) -> Result<(), Error>

Require at least one row by primary key.

Source

pub fn ensure_exists_many<I, V>(&self, values: I) -> Result<(), Error>
where I: IntoIterator<Item = V>, V: FieldValue,

Require that all provided primary keys exist.

Source

pub fn ensure_exists_filter<F, I>(&self, f: F) -> Result<(), Error>
where F: FnOnce(FilterDsl) -> I, I: IntoFilterExpr,

Require at least one row from a filter.

Source

pub fn explain(self, query: LoadQuery) -> Result<QueryPlan, Error>

Validate and return the query plan without executing.

Source

pub fn execute(&self, query: LoadQuery) -> Result<Response<E>, Error>

Execute a full query and return a collection of entities.

Note: index-backed loads are best-effort. If index entries point to missing or malformed rows, those candidates are skipped. Use explicit strict APIs when corruption must surface as an error.

Source

pub fn count(&self, query: LoadQuery) -> Result<u32, Error>

Count rows matching a query.

Source

pub fn count_all(&self) -> Result<u32, Error>

Source

pub fn group_count_by<K, F>( &self, query: LoadQuery, key_fn: F, ) -> Result<HashMap<K, u32>, Error>
where K: Eq + Hash, F: Fn(&E) -> K,

Group rows matching a query and count them by a derived key.

This is intentionally implemented on the executor (not Response) so it can later avoid full deserialization.

Trait Implementations§

Source§

impl<E: Clone + EntityKind> Clone for LoadExecutor<E>
where E::Canister: Clone,

Source§

fn clone(&self) -> LoadExecutor<E>

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<E: Copy + EntityKind> Copy for LoadExecutor<E>
where E::Canister: Copy,

Auto Trait Implementations§

§

impl<E> Freeze for LoadExecutor<E>

§

impl<E> RefUnwindSafe for LoadExecutor<E>

§

impl<E> Send for LoadExecutor<E>
where E: Send, <E as EntityKind>::Canister: Send,

§

impl<E> Sync for LoadExecutor<E>
where E: Sync, <E as EntityKind>::Canister: Sync,

§

impl<E> Unpin for LoadExecutor<E>
where E: Unpin, <E as EntityKind>::Canister: Unpin,

§

impl<E> UnwindSafe for LoadExecutor<E>

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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

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

Source§

fn vzip(self) -> V