Rindle docs and package mapSkip to main content

Query

Struct Query 

Source
pub struct Query { /* private fields */ }
Expand description

A registered live query. Subscribe to receive its raw change events.

Tear it down explicitly with Query::destroy. Dropping the handle is still a no-op (the query keeps running and any callbacks keep firing), so an accidental drop never silently stops delivery — teardown is always a deliberate call.

Implementations§

Source§

impl Query

Source

pub fn id(&self) -> QueryId

The caller-supplied QueryId tag this query was registered under (echoed verbatim; the engine never interprets it).

Source

pub fn destroy(self)

Tear this query down: stop delivering its events and reclaim its pipeline.

Removes its subscription registry entry (so no further Changed callbacks fire and the hydration buffer is dropped), then disconnects it from the shared sources and frees its operator/storage slots in the engine graph ([rindle::graph::Graph::destroy_pipeline]). The shared sources — and every other query — are untouched. Consumes the handle; the freed slots are recycled by a later crate::Db::query.

Like registration, this borrows the engine mutably, so it must not be called re-entrantly from inside a subscriber callback.

Source

pub fn subscribe(&self, cb: impl FnMut(&Update) + 'static)

Register a callback and immediately call it with the cached Update::Hydrated. This baseline is from registration or the latest shed recovery; ordinary writes do not update it. Subscribe before later writes. A late consumer that needs the current result should create a new query registration.

Later Changed callbacks run synchronously on the writer thread after commit. A callback panic cannot roll back that SQL commit. Keep callbacks short, avoid re-entering the Db, and forward events to a channel for other threads. A shed recovery delivers a replacing Hydrated; see Update. Call Query::destroy to stop the registration and all its callbacks.

A no-op (the callback is dropped without firing) in one edge: the query was torn down because its post-shed re-hydration failed (see crate::CommitInfo::shed).

Auto Trait Implementations§

§

impl Freeze for Query

§

impl !RefUnwindSafe for Query

§

impl !Send for Query

§

impl !Sync for Query

§

impl Unpin for Query

§

impl UnsafeUnpin for Query

§

impl !UnwindSafe for Query

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> 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, 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,