Skip to main content

Session

Struct Session 

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

Owner of one mutation line, its records, and its tracked documents.

Implementations§

Source§

impl Session

Source

pub fn new(storage: impl Storage + Send + 'static) -> Session

Open a Session over one storage backend. The first error a Storage call returns, other than a StorageError::Request from a read, fails the Session.

Source

pub fn with_clock( storage: impl Storage + Send + 'static, now: impl Fn() -> u64 + Send + Sync + 'static, ) -> Session

now is the wall clock (milliseconds) stamped on task lifecycle times.

Source

pub fn commit<T>( &self, change: impl FnOnce(&mut Tx<'_>) -> Result<T, SessionError>, ) -> Result<T, SessionError>

Run one atomic transaction on the mutation line. Its changes publish only after Storage acknowledges them.

Source

pub fn commit_with<T>( &self, scope: TxScope, change: impl FnOnce(&mut Tx<'_>) -> Result<T, SessionError>, ) -> Result<T, SessionError>

commit with defaults: the conversation of Tx::create_task and the task stamped on appended entries.

Source

pub fn snapshot( &self, doc: &Doc, owner: Owner, ) -> Result<Option<Arc<Value>>, SessionError>

The committed value of a document; never creates one.

Source

pub fn fail(&self, error: SessionError)

Fail the Session with error, the first failure wins: admission ends, close listeners run, every watch ends, and Storage closes. Must not be called on the mutation line (from a commit callback or listener).

Source

pub fn subscribe_commits( &self, listener: impl Fn(&CommitPublication) + Send + Sync + 'static, ) -> Result<Subscription, SessionError>

Observe complete commits synchronously after adoption, on the committing thread. The listener must not block or call Session APIs.

Source

pub fn subscribe_close( &self, listener: impl Fn() + Send + Sync + 'static, ) -> Result<Subscription, SessionError>

Observe close synchronously when it begins, also when a failed Storage call closes the Session.

Source

pub fn close(&self) -> Result<(), SessionError>

Seal admission, settle commits already admitted, then close Storage. Later calls wait for the first.

Source

pub fn wait_closed(&self) -> SessionEnd

Wait until the Session has closed, Storage included: after close(), or after the first failed Storage call.

Source

pub fn failure(&self) -> Option<SessionError>

Source

pub fn line_len(&self) -> u64

Jobs admitted to the mutation line and not yet finished, the running one included. Lets a caller (a test) know that a commit or close has queued behind another, instead of guessing with a sleep.

Trait Implementations§

Source§

impl Clone for Session

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§

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.

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