pub struct Database { /* private fields */ }Expand description
A cloneable handle to one owned database. The connection capability retains both the worker and its matching database context; this handle has no second path to either.
Implementations§
Source§impl Database
impl Database
pub async fn row_blob_ref( &self, table: &str, row_id: &str, ) -> Result<RowBlobRef, DbError>
Source§impl Database
impl Database
Sourcepub fn open(
path: &Path,
synced_tables: Vec<SyncedTable>,
blob_tombstone_grace: Duration,
transfer_limits: TransferLimits,
device_id: String,
clock: ClockRef,
coven_migration_policy: CovenMigrationPolicy,
migrations: &[Migration],
) -> Result<Database, OpenError>
pub fn open( path: &Path, synced_tables: Vec<SyncedTable>, blob_tombstone_grace: Duration, transfer_limits: TransferLimits, device_id: String, clock: ClockRef, coven_migration_policy: CovenMigrationPolicy, migrations: &[Migration], ) -> Result<Database, OpenError>
Open and own the connection at path.
Runs the host migration ladder and validates its final sync-routing
contract in one transaction. A fresh database creates Coven metadata in
that transaction; an initialized database commits only when the final
contract exactly matches its pinned bytes. Then seeds the register clock
from on-disk rows. The _updated_at stamper remains inside the database
boundary and is used by every synced-row write.
pub fn open_initialized_store( path: &Path, install: &VerifiedSnapshotBootstrapInstall, synced_tables: Vec<SyncedTable>, blob_tombstone_grace: Duration, transfer_limits: TransferLimits, device_id: String, clock: ClockRef, coven_migration_policy: CovenMigrationPolicy, migrations: &[Migration], ) -> Result<Database, OpenError>
pub fn open_in_store_dir_for_test( path: &Path, store_dir: StoreDir, synced_tables: Vec<SyncedTable>, blob_tombstone_grace: Duration, transfer_limits: TransferLimits, device_id: String, clock: ClockRef, coven_migration_policy: CovenMigrationPolicy, migrations: &[Migration], ) -> Result<Database, OpenError>
pub fn open_with_hlc_in_store_dir_for_test( path: &Path, store_dir: StoreDir, synced_tables: Vec<SyncedTable>, blob_tombstone_grace: Duration, transfer_limits: TransferLimits, hlc: Arc<Hlc>, coven_migration_policy: CovenMigrationPolicy, migrations: &[Migration], ) -> Result<Database, OpenError>
Sourcepub fn open_read_only(
path: &Path,
synced_tables: Vec<SyncedTable>,
blob_tombstone_grace: Duration,
transfer_limits: TransferLimits,
device_id: String,
clock: ClockRef,
migrations: &[Migration],
) -> Result<Database, OpenError>
pub fn open_read_only( path: &Path, synced_tables: Vec<SyncedTable>, blob_tombstone_grace: Duration, transfer_limits: TransferLimits, device_id: String, clock: ClockRef, migrations: &[Migration], ) -> Result<Database, OpenError>
Open the store at path read-only for a same-store secondary reader
(e.g. a separate process reading while another holds the writer open).
Distinct from Database::open in three ways, all so the reader never
mutates shared state a concurrent writer owns: the connection is
SQLITE_OPEN_READONLY; no migration ladder or bookkeeping DDL runs (it
opens against the schema the writer left, and refuses one newer than this
binary knows — the writer’s SchemaTooNew policy); and it returns no
stamper, because a reader mints no _updated_at. Reads are safe across
processes because a read-only connection can coexist with the writer and
observes commits after each read transaction ends.
The caller takes no store open-lock for a read-only open: the exclusive advisory lock guards against a second writer, and a read-only connection cannot write, so multiple readers can coexist with one writer.
Sourcepub fn open_with_hlc(
path: &Path,
synced_tables: Vec<SyncedTable>,
blob_tombstone_grace: Duration,
transfer_limits: TransferLimits,
hlc: Arc<Hlc>,
coven_migration_policy: CovenMigrationPolicy,
migrations: &[Migration],
) -> Result<Database, OpenError>
pub fn open_with_hlc( path: &Path, synced_tables: Vec<SyncedTable>, blob_tombstone_grace: Duration, transfer_limits: TransferLimits, hlc: Arc<Hlc>, coven_migration_policy: CovenMigrationPolicy, migrations: &[Migration], ) -> Result<Database, OpenError>
Open with a caller-supplied register clock instead of a fresh
system-wall-clock one. Lets a test inject an Hlc over a controlled
wall clock to exercise the skew/restart-seeding guarantees, sharing the
production open path (migration, seed, session) so the test drives the
real unit.
pub fn schema_version(&self) -> u32
pub fn sync_routing_hash(&self) -> ObjectHash
Sourcepub fn receive_wall_ms(&self) -> u64
pub fn receive_wall_ms(&self) -> u64
The receiver’s current wall-clock millis, read from this database’s
register clock. The pull reads it once and passes it down to bound an
incoming _updated_at’s physical component (a grossly-future stamp must not
win last-writer-wins or ratchet the clock).