Skip to main content

Query

Struct Query 

Source
pub struct Query<M: Model> { /* private fields */ }
Expand description

A live, typed result set over one model’s table: ids only, answered by the engine and kept current by dependency-gated requeries. Rows stay lazy: fault the ones you show (Query::materialize, or a list source doing it for you). Clone shares the same set.

Implementations§

Source§

impl<M: Model> Query<M>

Source

pub fn error(&self) -> Signal<Option<DbError>>

This query’s last read failure. A failed read preserves its previous result set.

Source

pub fn refresh(&self)

Explicitly retry a query after a transient read failure (also useful after external SQL).

Source

pub fn try_ids(&self) -> Result<Vec<ModelId<M>>, DbError>

Checked form of ids, for imports and commands that must not mistake failure for absence.

§Errors

Returns the query’s error when its last read failed.

Source

pub fn try_collect(&self) -> Result<Vec<M>, DbError>

A checked snapshot for non-UI work, fetched in batches. UI lists should use the query itself as their row source so they only materialize the visible working set.

§Errors

Returns the query’s error when its last read failed, or the storage or decoding error of a row that cannot be read.

Source

pub fn ids(&self) -> Vec<ModelId<M>>

The result ids, typed and in query order, as a tracked read: the caller re-runs when the set changes, and only then.

Source

pub fn count(&self) -> usize

The result count, tracked like Query::ids.

Source

pub fn first(&self) -> Option<ModelId<M>>

The first result, tracked.

Source

pub fn contains(&self, id: impl Into<ModelId<M>>) -> bool

Tracked membership test.

Source

pub fn ids_untracked(&self) -> Vec<ModelId<M>>

Untracked snapshot: reactively silent, but still current (pending staleness settles first, like every other read).

Source

pub fn materialize(&self, range: Range<usize>)

Bring this window of the result into the cache: what a list binding calls for the rows it is about to show, batched into one SELECT.

Source

pub fn set_fetch(&self, fetch: Fetch)

Swap the fetch (a changed filter or sort): requeries and reloads consumers. No-op when equal to the current one, so a query_fn closure can re-run cheaply.

Source

pub fn take_events(&self) -> QueryEvents

Drain what changed since the last call: the list source’s feed. Pending staleness settles first, so a drain right after an edit already narrates it.

Trait Implementations§

Source§

impl<M: Model> Clone for Query<M>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<M: Model> RowSource for Query<M>

list(query, row): the query’s ids are the display order, rows fault in as the list binds them (a window at a time), and set changes arrive as row deltas the native list can animate.

Source§

type Slot = ModelSlot<M>

What a row builder receives.
Source§

type Ref = Elem<M>

What selection callbacks hand the app.
Source§

type Conn = QueryConn<M>

Source§

fn connect(self) -> QueryConn<M>

Auto Trait Implementations§

§

impl<M> !RefUnwindSafe for Query<M>

§

impl<M> !Send for Query<M>

§

impl<M> !Sync for Query<M>

§

impl<M> !UnwindSafe for Query<M>

§

impl<M> Forget for Query<M>

§

impl<M> Freeze for Query<M>
where PhantomData<fn() -> M>: Freeze,

§

impl<M> Move for Query<M>

§

impl<M> Unpin for Query<M>
where PhantomData<fn() -> M>: Unpin,

§

impl<M> UnsafeUnpin for Query<M>
where PhantomData<fn() -> M>: UnsafeUnpin,

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> ErasedDestructor for T
where T: 'static,

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> IntoReactive<T, StaticMark> for T
where T: Clone + 'static,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.