Skip to main content

StoreDirAccess

Trait StoreDirAccess 

Source
pub trait StoreDirAccess: Sized {
Show 23 methods // Required methods fn database_path(&self) -> PathBuf; fn input_database_path(&self) -> PathBuf; 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 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 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 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 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", so this trait is not object safe.

Implementors§