Struct TursoStore
pub(crate) struct TursoStore {
conn: Connection,
stmts: Statements,
selects: Selects,
}tokio and turso only.Expand description
A turso-backed session store.
The mutating statements are prepared once at connect and
reused on every flush, so the SQL is parsed and planned only once.
Fields§
§conn: Connection§stmts: Statements§selects: SelectsImplementations§
§impl TursoStore
impl TursoStore
pub(crate) async fn connect(
database: &Database,
table_prefix: &str,
) -> Result<Self>
pub(crate) async fn connect( database: &Database, table_prefix: &str, ) -> Result<Self>
Opens a connection and runs pending migrations. Then prepares the statements.
§Errors
Returns an I/O error if the prefix is invalid, the connection cannot be opened, migrations fail, or a statement cannot be prepared.
pub(crate) async fn load(&mut self) -> Result<InMemory>
pub(crate) async fn load(&mut self) -> Result<InMemory>
Rebuilds the persisted session into a fresh session::InMemory.
§Errors
Returns an I/O error if a query fails or a stored row cannot be decoded back into valid session state.
pub(crate) async fn persist(
&mut self,
client: &mut Client<JournaledSession>,
) -> Result<()>
pub(crate) async fn persist( &mut self, client: &mut Client<JournaledSession>, ) -> Result<()>
Persists everything accumulated in client’s session since the last
call, clearing the in-memory buffer only on success so a failed write
keeps the ops buffered for the next attempt.
If the journal missed an op, the pending ops are incomplete. All rows are then replaced with a snapshot of the session instead.
async fn flush(&mut self, mode: Flush, ops: &Ops) -> Result<()>
async fn flush(&mut self, mode: Flush, ops: &Ops) -> Result<()>
Applies ops to the database in one transaction, reusing the prepared
statements. On failure the transaction is rolled back and the ops are
left for the next attempt.
async fn write(&mut self, mode: Flush, ops: &Ops) -> Result<()>
async fn apply_ops(&mut self, ops: &Ops) -> Result<()>
Auto Trait Implementations§
impl !Freeze for TursoStore
impl !RefUnwindSafe for TursoStore
impl !UnwindSafe for TursoStore
impl Send for TursoStore
impl Sync for TursoStore
impl Unpin for TursoStore
impl UnsafeUnpin for TursoStore
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