Skip to main content

StoreDirAccess

Trait StoreDirAccess 

Source
pub trait StoreDirAccess: Sized {
Show 35 methods // Required methods fn database_path(&self) -> PathBuf; fn input_database_path(&self) -> PathBuf; fn audience_database_path(&self) -> PathBuf; fn remove_audience_database(&self) -> Result<(), FileError>; fn rebuild_directory( &self, ) -> impl Future<Output = Result<Self, SettingsError>> + Send; fn remove_rebuild_directory(&self) -> Result<(), FileError>; fn retire_rebuild_directory(&self) -> Result<bool, FileError>; fn return_rebuild_directory(&self) -> Result<(), FileError>; fn remove_retired_rebuild(&self) -> Result<(), FileError>; fn unfinished_replacement( &self, ) -> Result<Option<ReplacementRecord>, SettingsError>; fn unfinished_deletion(&self) -> Result<Option<IfUnsent>, FileError>; fn record_deletion(&self, unsent: IfUnsent) -> Result<(), FileError>; fn forget_deletion(&self) -> Result<(), FileError>; fn discarded_devices(&self) -> Result<Vec<String>, FileError>; fn discarded_device_size(&self, name: &str) -> Result<u64, FileError>; fn retire_discarded_device(&self, name: &str) -> Result<bool, FileError>; fn return_discarded_device(&self, name: &str) -> Result<(), FileError>; fn remove_retired_devices(&self) -> Result<(), FileError>; fn settings(&self) -> Result<StoreSettings, SettingsError>; fn bugs(&self) -> &BugSinkRef; fn lock_for_open( &self, ) -> impl Future<Output = Result<StoreLock, StoreLockError>> + Send; fn lock_closed( &self, ) -> impl Future<Output = Result<ClosedStoreLock, StoreLockError>> + Send; fn lock_read_only(&self) -> Result<StoreReadLock, StoreLockError>; fn lock_cache_write(&self) -> Result<CacheWriteLock, FileError>; fn exclude_cache_writes(&self) -> Result<CacheWriteLock, FileError>; fn lock_for_deletion( &self, ) -> Result<Option<StoreDeletionLock>, StoreLockError>; fn closed(&self) -> impl Future<Output = Result<(), FileError>> + Send; fn owned_file(&self, file: StoreFile) -> AtomicFile; fn file(&self, area: FileArea, name: &FileName) -> AtomicFile; fn create_writer( &self, area: FileArea, name: &FileName, ) -> Result<FileWriter, WriterError>; fn writer_folder(&self, area: FileArea) -> Result<WriterFolder, WriterError>; fn staged_file(&self, name: &StagedName) -> AtomicFile; fn staging_folder( &self, folder: &FileName, batch: &mut FlushBatch, ) -> Result<WriterFolder, StagingFolderError>; fn remove_staged(&self, name: &StagedName) -> Result<(), FileError>; fn resume_writer( &self, area: FileArea, name: &FileName, length: u64, ) -> Result<FileWriter, WriterError>;
}
Expand description

Crate-to-crate operations for coven’s owners; not re-exported by the app API.

Required Methods§

Source

fn database_path(&self) -> PathBuf

The database file’s exact path for coven-database to open with SQLite. Callers never append path components to it.

Source

fn input_database_path(&self) -> PathBuf

Retained remote input has its own SQLite owner: receiving bytes must not wait for a transaction applying those bytes to the application database.

Source

fn audience_database_path(&self) -> PathBuf

The database a breaking migration’s per-audience check runs in, which lives only for that check (§18.3).

Source

fn remove_audience_database(&self) -> Result<(), FileError>

Remove that database’s file and the files SQLite keeps beside it; one that is absent is already removed.

Source

fn rebuild_directory( &self, ) -> impl Future<Output = Result<Self, SettingsError>> + Send

The store a rebuild runs in (§18.3): a store of its own in the folder rebuild of this store’s folder, with this store’s id and this device’s, the file areas empty and the class this layout gives the store’s files. A leftover from a crash goes first, once an instance of it in this process has finished closing. The caller removes it with Self::remove_rebuild_directory.

Source

fn remove_rebuild_directory(&self) -> Result<(), FileError>

Remove the folder rebuild whole, with its locks; absent is removed.

Source

fn retire_rebuild_directory(&self) -> Result<bool, FileError>

Move the folder rebuild aside, in one rename, so it leaves the store’s directory before coven deletes its files, after deleting what an earlier removal left there. Returns whether there was one to move.

Source

fn return_rebuild_directory(&self) -> Result<(), FileError>

Move the folder retire_rebuild_directory moved aside back.

Source

fn remove_retired_rebuild(&self) -> Result<(), FileError>

Delete the folder retire_rebuild_directory moved aside, whole. When that folder is absent, the call does nothing and succeeds. The database has no row for the files in that folder. Blocks while it deletes the folder.

Source

fn unfinished_replacement( &self, ) -> Result<Option<ReplacementRecord>, SettingsError>

The record of a replacement whose swap is under way (§19.3). A record that remains only because publication was interrupted after removing the bootstrap marker, with settings already naming the new device, is not returned; the next replacement removes it. Reads only.

Source

fn unfinished_deletion(&self) -> Result<Option<IfUnsent>, FileError>

What the store’s unfinished deletion does with unsent work, when this device recorded that it is deleting the store and leaving it (E1). Reads only.

Source

fn record_deletion(&self, unsent: IfUnsent) -> Result<(), FileError>

Record that this device is deleting the store and leaving it, with what the deletion does with unsent work, before it journals the device’s removal. The record goes with the directory.

Source

fn forget_deletion(&self) -> Result<(), FileError>

Remove the record of a deletion that ended before it journaled the device’s removal. An absent record succeeds.

Source

fn discarded_devices(&self) -> Result<Vec<String>, FileError>

The name of each archive that a reset kept in the store’s directory, in order (§19.3).

Source

fn discarded_device_size(&self, name: &str) -> Result<u64, FileError>

The size of everything in the archive name. Blocks while it walks the archive.

Source

fn retire_discarded_device(&self, name: &str) -> Result<bool, FileError>

Move the archive name out of the store’s directory, in one rename, into the folder where coven deletes retired archives. Returns whether it was there to move.

Source

fn return_discarded_device(&self, name: &str) -> Result<(), FileError>

Move the archive name back, as retire_discarded_device found it.

Source

fn remove_retired_devices(&self) -> Result<(), FileError>

Delete the folder that retire_discarded_device moved archives into, then sync the store’s directory. The database has no row for the archives in that folder, so a removal that stops partway leaves the rest for the next call. Blocks while it removes them.

Source

fn settings(&self) -> Result<StoreSettings, SettingsError>

The settings written when this store was created, restored or joined. Reading takes no lock; a read-only open uses it alongside a writer.

Source

fn bugs(&self) -> &BugSinkRef

Where a bug in the store’s work that nobody waits for goes (E15): the app’s own reporter, which its directories were given.

Source

fn lock_for_open( &self, ) -> impl Future<Output = Result<StoreLock, StoreLockError>> + Send

Take the writer lock, awaiting release by a closing instance in this process. A live instance or another process still refuses immediately.

Source

fn lock_closed( &self, ) -> impl Future<Output = Result<ClosedStoreLock, StoreLockError>> + Send

Take the writer lock to read a closed store without opening it: a live instance or another process refuses immediately, and an instance closing in this process is waited for. Registered as closing, so an open in this process waits for its release (api.md E1).

Source

fn lock_read_only(&self) -> Result<StoreReadLock, StoreLockError>

Prevent deletion while reading, alongside other readers and the writer. The guard must outlive every open file and database connection it protects.

Source

fn lock_cache_write(&self) -> Result<CacheWriteLock, FileError>

Hold while a cache range recorded as being written gets its bytes with no database writer held. Shared by such writes in every process; exclude_cache_writes waits for all of them (Appendix C.3).

Source

fn exclude_cache_writes(&self) -> Result<CacheWriteLock, FileError>

Wait until no cache range is being written in any process and keep new writes waiting, so a range still recorded as being written has no live writer (Appendix C.3).

Source

fn lock_for_deletion(&self) -> Result<Option<StoreDeletionLock>, StoreLockError>

Lock an existing store or a directory left by an interrupted deletion, holding its writer, reader and bootstrap locks so that removal takes every lock file named for the store. An absent store with leftover locks can finish their removal on retry. A running restore, join or replacement refuses with StoreLockError::AlreadyOpen. A store whose replacement is unfinished is locked for deletion; an unfinished first installation is refused with StoreLockError::BootstrapPending. No directory is created by this call.

Source

fn closed(&self) -> impl Future<Output = Result<(), FileError>> + Send

Wait until no instance of this store in this process is closing, as lock_for_open does, so a deletion that follows is not refused by an instance only finishing its close, a replacement’s loading installation in its hidden directory included. A live instance is not waited for.

Source

fn owned_file(&self, file: StoreFile) -> AtomicFile

Give a crate the capability for its reserved file, without exposing the store path or letting it name any other top-level file.

Source

fn file(&self, area: FileArea, name: &FileName) -> AtomicFile

The capability for one app-provided copy or cache entry. All path construction stays here; the name cannot traverse directories.

Source

fn create_writer( &self, area: FileArea, name: &FileName, ) -> Result<FileWriter, WriterError>

Create a named file in area for asynchronous streaming without replacing anything. The writer holds the store’s read lock until its handle and any cancelled I/O finish, so the store can’t be deleted under it. The caller records the name first and removes partial bytes after a failure.

Source

fn writer_folder(&self, area: FileArea) -> Result<WriterFolder, WriterError>

Hold area’s folder for a run of files made in it: the store’s read lock is taken and the folder resolved once, for every writer WriterFolder::create makes, each as create_writer’s does.

Source

fn staged_file(&self, name: &StagedName) -> AtomicFile

The capability for one staged copy, in its staging’s folder.

Source

fn staging_folder( &self, folder: &FileName, batch: &mut FlushBatch, ) -> Result<WriterFolder, StagingFolderError>

Make folder among the app-provided files for one staging’s copies, refusing one already there, and hold it as writer_folder holds an area’s folder. The app-provided files’ folder now holds the new folder, so batch‘s flush syncs it too (Appendix C.3). The caller records the copies’ names first, which name the folder.

Source

fn remove_staged(&self, name: &StagedName) -> Result<(), FileError>

Remove a staged copy, then its staging’s folder once nothing is in it, syncing the folder that held each (Appendix C.3). An absent copy or folder is gone.

Source

fn resume_writer( &self, area: FileArea, name: &FileName, length: u64, ) -> Result<FileWriter, WriterError>

Reopen a named file of area that an earlier writer left unfinished, for appending after its first length bytes, which the caller recorded as synced; anything past them is cut off. A file with fewer bytes is refused. The writer holds the store’s read lock as create_writer’s does.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§