Skip to main content

ReconfigurableLiveQuery

Struct ReconfigurableLiveQuery 

Source
pub struct ReconfigurableLiveQuery<Q, T, E> { /* private fields */ }
Expand description

A subscription whose request may be replaced while it runs. Its results fail with E, the query closure’s own error type.

Implementations§

Source§

impl<Q, T, E> ReconfigurableLiveQuery<Q, T, E>
where Q: Clone + PartialEq + Send + Sync + 'static, T: Send + 'static, E: CarriesBug + Send + 'static,

Source

pub fn new<F, R>( request: Q, run: Arc<dyn Fn(&Q, &CommitSubscription) -> Result<T, E> + Send + Sync>, failed: fn(Error<F, R>) -> E, handle: &Handle<F>, bugs: Arc<dyn BugSink>, ) -> ReconfigurableLiveQuery<Q, T, E>
where F: Clone + Send + Sync + 'static, R: 'static,

A query that answers request first, with run, on handle; its error type holds the engine’s errors through failed.

Source

pub fn runs(&self) -> LiveQueryRuns

How often this query has run so far, its processed form’s runs too.

Source

pub fn is_marked_for_rerun(&self) -> bool

Whether a commit since this idle query’s last result changes what it reads, so asking for its next result runs it again. A commit marks the queries it changes as it commits, so this answers with no waiting.

Source

pub fn bugs(&self) -> &Arc<dyn BugSink> ⓘ

Where a bug in a result nobody waits for any more goes (E15).

Source

pub fn has_pending_request(&self) -> bool

Whether a request waits for a run to answer it.

Source

pub fn requests(&self) -> LiveQueryRequests<Q>

Obtain a cloneable handle for replacing this query’s request.

Source

pub fn process<P, U>(self, process: P) -> ReconfigurableLiveQuery<Q, U, E>
where T: Clone + PartialEq, P: Fn(T) -> Result<U, E> + Send + Sync + 'static, U: Send + 'static,

Process each value after its run releases the connection. Equality compares processed values; request handles and event metadata remain.

Source

pub fn changed(&self) -> impl Future<Output = ()> + Send + 'static

Resolves once next_blocking has something to do: a commit changed what the last run read, a new request came, the handle failed or closed, the query ended, or no run has answered yet. Dropping it loses nothing, and it needs no runtime.

Source

pub fn run_changed(&mut self) -> Option<ReconfigurableLiveQueryEvent<Q, T, E>>
where T: Clone + PartialEq,

Runs the query once if a commit changed what its last run read, a new request came, the handle failed or closed, or no run has answered yet. Returns None when nothing changed, when a write-caused result equals the last one (the skip LiveQueryRuns counts), and once the query has ended. Never parks.

Source

pub fn has_ended(&self) -> bool

Whether the database closed, the handle failed or a run’s error carried a bug, and a result said so: the query answers nothing more.

Source

pub fn next_blocking(&mut self) -> Option<ReconfigurableLiveQueryEvent<Q, T, E>>
where T: Clone + PartialEq,

Return the next result and its request, as changed waits for it: this thread parks until a commit or a request calls for a run, and then run_changed runs the query on it, again if a write-caused result equals the last. Once the database is closed, or the handle fails every call, one result reports why and every later call returns None. So does a run whose error carries a bug, as one that panicked does with Error::Bug: what it read is unknown, so no commit could tell whether to run it again (E15).

Source

pub async fn next_inline( &mut self, ) -> Option<ReconfigurableLiveQueryEvent<Q, T, E>>
where T: Clone + PartialEq,

next_blocking for a test on an async executor: changed().await, then run_changed on the executor’s thread.

Auto Trait Implementations§

§

impl<Q, T, E> !RefUnwindSafe for ReconfigurableLiveQuery<Q, T, E>

§

impl<Q, T, E> !UnwindSafe for ReconfigurableLiveQuery<Q, T, E>

§

impl<Q, T, E> Freeze for ReconfigurableLiveQuery<Q, T, E>
where T: Freeze, Q: Freeze,

§

impl<Q, T, E> Send for ReconfigurableLiveQuery<Q, T, E>
where T: Send, Q: Send,

§

impl<Q, T, E> Sync for ReconfigurableLiveQuery<Q, T, E>
where T: Sync, Q: Sync + Send,

§

impl<Q, T, E> Unpin for ReconfigurableLiveQuery<Q, T, E>
where T: Unpin, Q: Unpin,

§

impl<Q, T, E> UnsafeUnpin for ReconfigurableLiveQuery<Q, T, E>
where T: UnsafeUnpin, Q: 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
§

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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 = !

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

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more