Skip to main content

Module turso

Module turso 

Available on crate features tokio and turso only.
Expand description

Optional [turso] persistence backend.

Stores session state as live, queryable rows in a turso (SQLite-compatible) database rather than as a CRC-framed journal file. Each session mutation is applied as an INSERT OR REPLACE / DELETE / UPDATE. The tables always contain the current state. Load is a set of SELECTs and there is no log replay or compaction.

The caller owns the [Database] (which it may share with its own application tables) and finmqtt opens its own Connection from it, so finmqtt’s transactions never interleave with the caller’s. finmqtt prefixes its table names so they coexist with other tables, and the schema is versioned per prefix (see schema) so it can evolve over time.

§Concurrency

A table prefix identifies exactly one session: at most one live client may use a database + prefix combination at a time. Like the file journal, this backend does not enforce mutual exclusion. Clients that share a prefix would silently corrupt each other’s session state. Give each client its own prefix (or database).

Modules§

convert 🔒
Conversions between turso rows/values and finmqtt types, plus error helpers shared across the turso backend.
row_error 🔒
schema 🔒
Prefixed table names and forward schema migrations.
store 🔒
Runtime turso store with a connection and the prepared statements that flush ops and rebuild the session.

Structs§

TursoPersistence
Configures session persistence backed by a turso database.

Enums§

Source 🔒
Where the database comes from.

Constants§

DEFAULT_TABLE_PREFIX 🔒
Default prefix for the names of all tables that finmqtt creates.

Functions§

open_local 🔒
Opens a local turso database file.