pub struct RebuildDatabase { /* private fields */ }Expand description
A rebuild’s store, open at the version its circle is at. Its owner is the
only one that writes to it or closes it; discard closes it and removes
its folder.
Implementations§
Source§impl RebuildDatabase
impl RebuildDatabase
Sourcepub async fn migrate_store_to(
&mut self,
circle: Audience,
version: u32,
) -> Result<(), RebuildError>
pub async fn migrate_store_to( &mut self, circle: Audience, version: u32, ) -> Result<(), RebuildError>
Migrate the rebuild’s store, which holds only the store, up to
version, the version of the circle about to load, with no migration
write: the store’s changes come only from the store, so the rows are
the ones every device that raised the store to version made, and
the device’s own marker belongs to the migration past it (§18.3). The
store is closed and opened again with the app’s migrations before the
first breaking one past version.
A failure removes the rebuild’s folder, as open_rebuild does.
Sourcepub async fn migrate(&mut self, header: WriteHeader) -> Result<(), RebuildError>
pub async fn migrate(&mut self, header: WriteHeader) -> Result<(), RebuildError>
Run the app’s migrations the rebuild’s store hasn’t, in one run, the
breaking ones making the migration write header and not a new one:
the device’s migration write for this rebuild, which read the circle
through the slot the store has applied (§18.3). The store is closed
and opened again at the app’s newest version; the per-audience check
of the run’s reads (§18.3) runs here as on any breaking open.
A failure removes the rebuild’s folder, as open_rebuild does; the
caller’s discard after it finds nothing left.
Sourcepub async fn export(
self,
id: SnapshotId,
key: KeyId,
into: &StoreDatabase,
) -> Result<SnapshotStaging, RebuildError>
pub async fn export( self, id: SnapshotId, key: KeyId, into: &StoreDatabase, ) -> Result<SnapshotStaging, RebuildError>
Stage the circle’s counted state at the slot the rebuild’s store has
applied into into as the snapshot id, sealed under key, then
remove the rebuild (§18.3). The rows are the circle’s, migrated, as
a device that held the circle and migrated would write them; the
raise captures the rebuild’s store made are not consulted, since it
sends nothing. Returns the staging, finished, for the caller to load;
on a failure the rebuild is removed, nothing stays staged in into
and the failure is returned.
Source§impl RebuildDatabase
impl RebuildDatabase
Sourcepub async fn stage_snapshot(
&self,
id: SnapshotId,
prefix: SnapshotObjectPrefix,
) -> Result<SnapshotStaging, DbError>
pub async fn stage_snapshot( &self, id: SnapshotId, prefix: SnapshotObjectPrefix, ) -> Result<SnapshotStaging, DbError>
Begin staging a snapshot into the rebuild’s store (§16.2).
Sourcepub async fn load<P: PendingValue, W>(
&self,
reload: SnapshotReload<SnapshotStaging, DownloadedWriteStream<W>>,
store_through: u64,
) -> Result<Vec<LoadedSnapshot>, DbError>
pub async fn load<P: PendingValue, W>( &self, reload: SnapshotReload<SnapshotStaging, DownloadedWriteStream<W>>, store_through: u64, ) -> Result<Vec<LoadedSnapshot>, DbError>
Load snapshots staged here and the slots after them into the rebuild’s store, as a device loads them (§16.2).
The store’s parts in slots after store_through aren’t read: past the
slot before the store’s raise beyond the circle’s version, the store
holds no rows at the circle’s version. A write above the rebuild’s
version is kept as a frozen lost value naming the breaking version it
needs, not waited for (§18.3).
Sourcepub async fn discard(self) -> Result<(), RebuildError>
pub async fn discard(self) -> Result<(), RebuildError>
Close the rebuild’s store and remove its folder with its row in the
real store’s coven_library_bytes, reporting the first failure
(both, as Cleanup, when both fail).