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>
impl<Q, T, E> ReconfigurableLiveQuery<Q, T, E>
Sourcepub 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>
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>
A query that answers request first, with run, on handle; its
error type holds the engine’s errors through failed.
Sourcepub fn runs(&self) -> LiveQueryRuns
pub fn runs(&self) -> LiveQueryRuns
How often this query has run so far, its processed form’s runs too.
Sourcepub fn is_marked_for_rerun(&self) -> bool
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.
Sourcepub fn bugs(&self) -> &Arc<dyn BugSink> ⓘ
pub fn bugs(&self) -> &Arc<dyn BugSink> ⓘ
Where a bug in a result nobody waits for any more goes (E15).
Sourcepub fn has_pending_request(&self) -> bool
pub fn has_pending_request(&self) -> bool
Whether a request waits for a run to answer it.
Sourcepub fn requests(&self) -> LiveQueryRequests<Q>
pub fn requests(&self) -> LiveQueryRequests<Q>
Obtain a cloneable handle for replacing this query’s request.
Sourcepub fn process<P, U>(self, process: P) -> ReconfigurableLiveQuery<Q, U, E>
pub fn process<P, U>(self, process: P) -> ReconfigurableLiveQuery<Q, U, E>
Process each value after its run releases the connection. Equality compares processed values; request handles and event metadata remain.
Sourcepub fn changed(&self) -> impl Future<Output = ()> + Send + 'static
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.
Sourcepub fn run_changed(&mut self) -> Option<ReconfigurableLiveQueryEvent<Q, T, E>>
pub fn run_changed(&mut self) -> Option<ReconfigurableLiveQueryEvent<Q, T, E>>
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.
Sourcepub fn has_ended(&self) -> bool
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.
Sourcepub fn next_blocking(&mut self) -> Option<ReconfigurableLiveQueryEvent<Q, T, E>>
pub fn next_blocking(&mut self) -> Option<ReconfigurableLiveQueryEvent<Q, T, E>>
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).
Sourcepub async fn next_inline(
&mut self,
) -> Option<ReconfigurableLiveQueryEvent<Q, T, E>>
pub async fn next_inline( &mut self, ) -> Option<ReconfigurableLiveQueryEvent<Q, T, E>>
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>
impl<Q, T, E> Send for ReconfigurableLiveQuery<Q, T, E>
impl<Q, T, E> Sync for ReconfigurableLiveQuery<Q, T, E>
impl<Q, T, E> Unpin for ReconfigurableLiveQuery<Q, T, E>
impl<Q, T, E> UnsafeUnpin for ReconfigurableLiveQuery<Q, T, E>where
T: UnsafeUnpin,
Q: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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