pub struct StoreDir { /* private fields */ }Expand description
One store’s directory, owning the paths to its database, app-provided files, cache, settings and sibling locks. It never exposes the directory as a raw path.
Implementations§
Source§impl StoreDir
impl StoreDir
Sourcepub fn is_unpublished(&self) -> Result<bool, FileError>
pub fn is_unpublished(&self) -> Result<bool, FileError>
Whether the store is still an unpublished installation: its marker is there (§13.4).
Sourcepub fn delete_discarded_devices(&self) -> Result<(), FileError>
pub fn delete_discarded_devices(&self) -> Result<(), FileError>
Remove the installations resets kept in this store’s directory (§19.3). The store’s own files stay. A failure midway leaves the rest for the next call; with none left it succeeds.
Sourcepub fn local_bytes(&self) -> Result<DirectoryBytes, FileError>
pub fn local_bytes(&self) -> Result<DirectoryBytes, FileError>
What this store’s directory holds, in file sizes (§17.8, §19.3): its own files, apart from the cache, and the installations resets kept.
Trait Implementations§
Source§impl StoreDirAccess for StoreDir
impl StoreDirAccess for StoreDir
Source§fn database_path(&self) -> PathBuf
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
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>
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>
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>
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>
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>
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
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§async fn lock_for_open(&self) -> Result<StoreLock, StoreLockError>
async fn lock_for_open(&self) -> Result<StoreLock, StoreLockError>
Take the writer lock, awaiting release by a closing instance in this
process. A live instance or another process still refuses immediately.
Source§async fn lock_closed(&self) -> Result<ClosedStoreLock, StoreLockError>
async fn lock_closed(&self) -> Result<ClosedStoreLock, StoreLockError>
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>
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>
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>
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>
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§async fn closed(&self) -> Result<(), FileError>
async fn closed(&self) -> Result<(), FileError>
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
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
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>
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>
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 resume_writer(
&self,
area: FileArea,
name: &FileName,
length: u64,
) -> Result<FileWriter, WriterError>
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.Source§fn staged_file(&self, name: &StagedName) -> AtomicFile
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>
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>
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§impl StoreLockProbe for StoreDir
Available on crate features test-utils only.
impl StoreLockProbe for StoreDir
Available on crate features
test-utils only.Source§fn lock_exclusive(&self) -> Result<StoreLock, StoreLockError>
fn lock_exclusive(&self) -> Result<StoreLock, StoreLockError>
Take the writer lock, refusing at once when it is held.
Auto Trait Implementations§
impl Freeze for StoreDir
impl !RefUnwindSafe for StoreDir
impl Send for StoreDir
impl Sync for StoreDir
impl Unpin for StoreDir
impl UnsafeUnpin for StoreDir
impl !UnwindSafe for StoreDir
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more