pub struct DatabaseBuilder { /* private fields */ }Expand description
Choices needed to open the database part of a store.
Implementations§
Source§impl DatabaseBuilder
impl DatabaseBuilder
Sourcepub fn new(directory: StoreDir) -> Self
pub fn new(directory: StoreDir) -> Self
Begin an open using a directory supplied by the store layout.
Sourcepub fn refuse_close(self) -> Self
pub fn refuse_close(self) -> Self
Have SQLite refuse to close the opened store’s writer.
Sourcepub fn subscribe_progress(&self) -> ProgressWatch<OpenStep>
pub fn subscribe_progress(&self) -> ProgressWatch<OpenStep>
The steps a writable open reports as it runs them, each with how much of it is done (§4). A read-only open runs none.
Sourcepub fn synced_tables(self, tables: Vec<SyncedTable>) -> Self
pub fn synced_tables(self, tables: Vec<SyncedTable>) -> Self
The tables that sync, described at the newest app schema version.
Sourcepub fn namespaces(self, namespaces: Vec<Namespace>) -> Self
pub fn namespaces(self, namespaces: Vec<Namespace>) -> Self
The file namespaces, each with its kind and cache budget (§17.1).
Sourcepub fn migrations(self, migrations: Vec<Migration>) -> Self
pub fn migrations(self, migrations: Vec<Migration>) -> Self
The complete app migration sequence, numbered from one.
Sourcepub fn loading_store(self) -> Self
pub fn loading_store(self) -> Self
Open an installation that loads its store from storage next, for a join, restore or reset: its breaking migrations make no migration write, since the device isn’t registered yet and the load replaces what they changed (§18.4).
Sourcepub fn migration_operation<F>(self, operation: F) -> Self
pub fn migration_operation<F>(self, operation: F) -> Self
Let sync describe the operation that publishes a breaking migration batch. The database commits its step 1 with the schema, converted waiting writes and migration write. A factory error rolls all of them back. Standalone database users may omit this; the application composition root supplies it.
Sourcepub fn joining_write<F>(self, write: F) -> Self
pub fn joining_write<F>(self, write: F) -> Self
The app’s write for a member’s device as its registration applies (§13.2): it runs in the transaction that first applies this device’s registration, as a local write, with the facts of its member’s latest admission. Without one, nothing runs.
Sourcepub fn before_commit<F>(self, function: F) -> Self
pub fn before_commit<F>(self, function: F) -> Self
The app’s before-commit function (§9.4): coven runs it last in each transaction that changes the app’s rows, a local write, a bulk write, an applied slot, a snapshot load or a migration as the store opens, so the app stores what its own rules compute from them in the same transaction. It writes device-local tables only, and its error fails the transaction. Without one, nothing runs.
Sourcepub fn id_source(self, ids: IdSourceRef) -> Self
pub fn id_source(self, ids: IdSourceRef) -> Self
The source of fresh names for this store’s owned file bytes (Appendix C.3).
Sourcepub fn sqlite_settings(self, settings: SqliteSettings) -> Self
pub fn sqlite_settings(self, settings: SqliteSettings) -> Self
SQLite settings for every connection to the store’s database; unset
ones keep SQLite’s defaults, except that checkpoint_fullfsync is on
for macOS and iOS (§4).
Sourcepub fn sql_functions(self, functions: SqlFunctions) -> Self
pub fn sql_functions(self, functions: SqlFunctions) -> Self
The app’s collations and scalar functions, registered on every connection to the store’s database before any app SQL runs on it (§4).
Sourcepub fn sync_functions(self, functions: SyncFunctions) -> Self
pub fn sync_functions(self, functions: SyncFunctions) -> Self
Sync’s computations of the sync state and of each upload’s phase,
which coven_sync_state and coven_upload_phases call as
_coven_sync_state and _coven_upload_phase, registered on every
connection with the functions coven’s views call (§17.9, §19.1).
coven’s own builder always gives them; a store opened without them
fails each read of either view.
Sourcepub async fn open(self) -> Result<StoreDatabase, OpenError>
pub async fn open(self) -> Result<StoreDatabase, OpenError>
Open one writer under the store lock and four read-only connections. Create coven’s internal tables when the database holds none, then rebuild the indexes a new version of SQLite or of the app’s collations and functions changes, then migrate the app’s schema.
Sourcepub async fn open_locked(
self,
lock: StoreLock,
) -> Result<StoreDatabase, OpenError>
pub async fn open_locked( self, lock: StoreLock, ) -> Result<StoreDatabase, OpenError>
Open under a lock already held by the facade while checking restored device identity. The lock must protect this builder’s directory.
Sourcepub async fn open_read_only(self) -> Result<StoreDatabase<ReadOnly>, OpenError>
pub async fn open_read_only(self) -> Result<StoreDatabase<ReadOnly>, OpenError>
Open read-only connections under a shared deletion guard, without migrating or rebuilding, including from a second process while the writer is open.