pub struct SessionStore { /* private fields */ }Expand description
SQLite-backed session authority and delivery outbox.
Implementations§
Source§impl SessionStore
impl SessionStore
Sourcepub fn open(path: impl AsRef<Path>) -> Result<SessionStore, SessionStoreError>
pub fn open(path: impl AsRef<Path>) -> Result<SessionStore, SessionStoreError>
Open or create a durable SQLite session database.
§Errors
Returns SessionStoreError if SQLite cannot open/configure the file,
the schema is newer or malformed, or an atomic migration fails.
Sourcepub fn open_in_memory() -> Result<SessionStore, SessionStoreError>
pub fn open_in_memory() -> Result<SessionStore, SessionStoreError>
Create an isolated in-memory store, primarily for tests.
§Errors
Returns SessionStoreError if SQLite initialization, schema creation,
or connection configuration fails.
Sourcepub fn load(
&self,
session_id: &str,
chain_id: u64,
) -> Result<PersistedSession, SessionStoreError>
pub fn load( &self, session_id: &str, chain_id: u64, ) -> Result<PersistedSession, SessionStoreError>
Load a session, returning an empty state when it has never connected.
§Errors
Returns SessionStoreError for a database/decode failure or when the
persisted row violates its identity, revision, cursor, delivery, or
reorg invariants.
Sourcepub fn apply_desired_state(
&mut self,
request: ApplyDesiredState,
) -> Result<DesiredStateApplied, SessionStoreError>
pub fn apply_desired_state( &mut self, request: ApplyDesiredState, ) -> Result<DesiredStateApplied, SessionStoreError>
Atomically compare-and-swap desired state and enqueue its activation barrier.
§Errors
Returns SessionStoreError when validation or revision comparison
fails, another delivery is pending, sequence/integer/size bounds are
exceeded, or SQLite cannot commit the transaction. Failure performs no
partial desired-state transition.
Sourcepub fn apply_desired_state_with_cursor(
&mut self,
request: ApplyDesiredState,
prepared_cursor: Option<&Cursor>,
) -> Result<DesiredStateApplied, SessionStoreError>
pub fn apply_desired_state_with_cursor( &mut self, request: ApplyDesiredState, prepared_cursor: Option<&Cursor>, ) -> Result<DesiredStateApplied, SessionStoreError>
Atomically replace desired state using the source-prepared activation cursor that will become authoritative when its barrier is acknowledged.
§Errors
Returns SessionStoreError for any invalid desired state or prepared
cursor, revision/pending-delivery conflict, exhausted bound, or database
failure. Failure leaves both authority and outbox unchanged.
Sourcepub fn save_pending(
&mut self,
desired_state: &ApplyDesiredState,
delivery: &Delivery,
) -> Result<(), SessionStoreError>
pub fn save_pending( &mut self, desired_state: &ApplyDesiredState, delivery: &Delivery, ) -> Result<(), SessionStoreError>
Persist the only delivery that may be in flight for a session.
§Errors
Returns SessionStoreError when the session is unknown, the desired
state is not authoritative, the delivery is invalid/oversized, a
different delivery is pending, or SQLite cannot persist it.
Sourcepub fn acknowledge(
&mut self,
chain_id: u64,
acknowledgement: &Acknowledge,
) -> Result<Cursor, SessionStoreError>
pub fn acknowledge( &mut self, chain_id: u64, acknowledgement: &Acknowledge, ) -> Result<Cursor, SessionStoreError>
Commit a matching delivery and cursor, clearing the durable outbox.
§Errors
Returns SessionStoreError when the session or pending delivery is
missing, the token/sequence does not match, persisted data is invalid,
or SQLite cannot atomically commit the cursor and clear the outbox.
Auto Trait Implementations§
impl !Freeze for SessionStore
impl !RefUnwindSafe for SessionStore
impl !Sync for SessionStore
impl !UnwindSafe for SessionStore
impl Send for SessionStore
impl Unpin for SessionStore
impl UnsafeUnpin for SessionStore
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> 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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request