Struct TursoStore
pub struct TursoStore {
conn: Connection,
stmts: Statements,
selects: Selects,
}turso only.Expand description
A turso-backed session store.
All 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, runs pending migrations, and 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<InMemorySession>
pub(crate) async fn load(&mut self) -> Result<InMemorySession>
Rebuilds the persisted session into a fresh InMemorySession.
§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.
async fn flush(&mut self, ops: &SessionOps) -> Result<()>
async fn flush(&mut self, ops: &SessionOps) -> Result<()>
Applies all ops to the database in a single transaction, reusing the
prepared statements. On failure the transaction is rolled back and the
ops are left for the next attempt.
async fn apply_ops(&mut self, ops: &SessionOps) -> Result<()>
Auto Trait Implementations§
impl !Freeze for TursoStore
impl !RefUnwindSafe for TursoStore
impl Send for TursoStore
impl Sync for TursoStore
impl Unpin for TursoStore
impl !UnwindSafe 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<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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 more