Skip to main content

StoreDir

Struct StoreDir 

Source
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

Source

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

Whether the store is still an unpublished installation: its marker is there (§13.4).

Source

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.

Source

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.

Source

pub fn id(&self) -> StoreId

The store identified by this directory.

Source

pub fn area_path(&self, area: FileArea) -> PathBuf

The folder of the store’s file area, for a test that looks at the files coven keeps there.

Trait Implementations§

Source§

impl Clone for StoreDir

Source§

fn clone(&self) -> StoreDir

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for StoreDir

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl StoreDirAccess for StoreDir

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) -> &Arc<dyn BugSink>

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>

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>

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§

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

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 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

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§

impl StoreLockProbe for StoreDir

Available on crate features test-utils only.
Source§

fn lock_exclusive(&self) -> Result<StoreLock, StoreLockError>

Take the writer lock, refusing at once when it is held.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,