Skip to main content

Handle

Struct Handle 

Source
pub struct Handle<F> { /* private fields */ }
Expand description

The failure state and the subscriptions that several databases share: a failure in one fails every later call and live query on each, with the host’s failure type F.

Implementations§

Source§

impl<F: Clone + Send + Sync + 'static> Handle<F>

Source

pub fn new(bugs: BugSinkRef, unrecorded: Vec<String>) -> Self

A handle whose bugs outside its calls go to bugs, and whose databases’ writes record no changes to the tables unrecorded names for live queries.

Source

pub fn recording_all(bugs: BugSinkRef) -> Self

A test handle for which every table records its changes.

Source

pub fn unrecorded(&self) -> &Arc<UnrecordedTables> ⓘ

The tables whose changes no write records.

Source

pub fn refuse_upkeep_thread_after(&self, started: Option<usize>)

Let started upkeep threads start, if given, and refuse the next.

Source

pub fn upkeep_thread_refused(&self) -> bool

Whether the system refuses the upkeep thread starting now.

Source

pub fn subscribe(&self) -> CommitSubscription

Observe every commit from now on.

Source

pub fn subscribe_outside( &self, outside: Option<CommitScope>, ) -> CommitSubscription

Observe every commit except those made within outside. Once the database has closed, a new subscription reports that it closed, as a call to the database does, not the failure it may have closed with.

Source

pub fn changes<R: 'static, E: 'static>( &self, reads: ReadSet, first: bool, failed: fn(Error<F, R>) -> E, ) -> DatabaseChanges<E>

Watch reads from now on; first reports the state now as their first change.

Source

pub fn attempt(&self, attempt: CommitScope) -> AttemptCommits

Keep every commit made from now on outside attempt, until the attempt names the rows it waits on (watch_attempt).

Source

pub fn watch_attempt<R: 'static, E: 'static>( &self, attempt: AttemptCommits, reads: ReadSet, failed: fn(Error<F, R>) -> E, ) -> DatabaseChanges<E>

Watch reads after attempt: the returned changes report at once a commit since the attempt began that changed what they read, as evidence against the wait the attempt ended in.

Source

pub fn judge( &self, changes: Vec<RowChange>, scope: Option<CommitScope>, lookups: &mut Lookups<'_>, ) -> Result<Judged>

Judge a write’s changes, made within scope, for every live query waiting on known reads that isn’t already marked to run again and that the changes could affect, with lookups reading the write’s transaction before it commits (§4).

Source

pub fn changed_without_write(&self, columns: &[(&str, &str)])

Tell live queries that each of columns, a (table, column) pair of a view, changed with no write: each query that read one runs again.

Source

pub fn commit(&self, judged: Judged, scope: Option<CommitScope>)

Report a commit made within scope, if any. A query still waiting on the reads it was judged against takes its verdict. One running keeps the changes, to judge against its run’s snapshot as it finishes. One that finished another run since, or wasn’t judged, judges the changes counting every join’s value as matched: their transaction has ended, so no lookup can read it. A waiting query the index finds for none of the changes is affected by none of them.

Source

pub fn kept_columns(&self) -> BTreeMap<String, BTreeSet<String>>

The columns some subscription reads or its scope tests, by table, all lowercase: a waiting one’s, or a running one’s previous run’s. Each table such a subscription reads is here, with no column where it reads none. A write keys the rows it changes in these tables and keeps those values of them, so it can tell each row’s net change and test the row against the scopes (net_changes.rs). A change to any other table needs no values to wake the subscriptions that read it.

Source

pub fn error<R>(&self) -> Option<Error<F, R>>

What every call on the handle fails with: its failure, or Error::Closed once it closed.

Source

pub fn has_failed(&self) -> bool

Whether the handle failed: a handle its host only closed hasn’t.

Source

pub fn fail(&self, failure: F)

Fail every later call and subscription with failure. The handle keeps the first failure and ignores later ones.

Source

pub fn fail_engine<R>(&self, failure: EngineFailure<F, R>)
where F: From<EngineFailure<F, R>>,

Fail every later call and subscription with the host’s failure made from failure, one of sqlive’s own.

Source

pub fn fail_with_bug(&self, bug: Bug)

Fail the handle with bug, a panic in work that may have held its state or a fault a drop found in it. The handle fails with this bug, not the one a poisoned lock would name. The bug goes to one reporter: the handle’s call this thread runs, which returns it as its own (calling), or the handle’s bug sink, outside such a call or once the call has a bug of its own already (E15).

Source

pub fn calling<R>(&self, call: impl FnOnce() -> R) -> (R, Option<Bug>)

Run call, one of this handle’s calls, on this thread. Beside its result comes the bug its own work failed the handle with, if any, which the call returns as its own (E15). A call that unwinds leaves that bug to the sink: its panic is the call’s bug then. A call made inside another on the same handle is part of it, and leaves its bug to the outer one, which the app hears from.

Source

pub fn report(&self, bug: &Bug)

Hand bug, which no call returns, to the handle’s bug sink (E15).

Source

pub fn close(&self)

Close the handle: every subscription and later call reports it.

Source

pub fn test_poison(&self)

Panic while holding the handle’s state, as a bug in judging a commit for live queries would.

Trait Implementations§

Source§

impl<F: Clone> Clone for Handle<F>

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

Auto Trait Implementations§

§

impl<F> !RefUnwindSafe for Handle<F>

§

impl<F> !UnwindSafe for Handle<F>

§

impl<F> Freeze for Handle<F>

§

impl<F> Send for Handle<F>

§

impl<F> Sync for Handle<F>

§

impl<F> Unpin for Handle<F>

§

impl<F> UnsafeUnpin for Handle<F>

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.

§

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

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