Skip to main content

Coven

Struct Coven 

Source
pub struct Coven { /* private fields */ }
Expand description

This app’s stores on this device (E1): the app directory each has its own directory under, the OS keychain service their keys and secrets are kept under, and the device’s network, which each open store watches. The app builds one at startup and holds it.

Implementations§

Source§

impl Coven

Source

pub fn in_memory(app_dir: PathBuf) -> Self

An installation for a test: its stores under app_dir, a keychain with no device-only entries and none of the person’s entries, isolated from the OS and other tests, and a usable network that isn’t metered, which the test drives. A new one simulates another device; keep one to test reopening.

Source

pub fn in_memory_reporting_to(app_dir: PathBuf, bugs: BugSinkRef) -> Self

in_memory, whose bugs in work nobody waits for go to bugs, for a test that hears them (E15).

Source

pub fn in_memory_with_saved_keychain( app_dir: PathBuf, path: &Path, ) -> Result<Self, KeyError>

An installation, as in_memory makes, whose keychain’s device-only entries are the ones save_device_keychain saved at path: the same device again, which opens the stores it had, as a test reopens a kept copy of a store in another process. Its person entries start empty.

Source

pub fn with_block_store(app_dir: PathBuf) -> Self

An installation on an Android phone: its person entries behave as Block Store keeps them, this phone’s own, with Block Store’s limits (§13.1).

Source

pub fn another_device(&self, app_dir: PathBuf) -> Self

Another device of the same person, its stores under app_dir: an installation with its own empty device-only keychain. With iCloud Keychain it shares this one’s person entries, as iCloud Keychain carries a restore code and S3 key between the person’s devices; with Block Store it has its own, empty.

Source

pub fn set_up_new_device(&self, app_dir: PathBuf) -> Self

A new phone set up from this one by direct transfer, its stores under app_dir: nothing of this phone’s own, and a copy of its Block Store entries (§13.1). Requires with_block_store.

Source

pub fn restore_new_device_from_cloud(&self, app_dir: PathBuf) -> Self

A new phone set up from this phone’s last cloud backup, its stores under app_dir: the Block Store entries that backup holds (§13.1). Requires with_block_store.

Source

pub fn back_up_to_cloud(&self)

Google’s periodic cloud backup of this phone’s Block Store: the entries stored while end-to-end encryption was available. Requires with_block_store.

Source

pub fn set_end_to_end_encryption(&self, available: bool)

Whether this phone’s cloud backup would be end-to-end encrypted: it has a screen lock. Requires with_block_store.

Source

pub async fn create_closed_store( &self, name: &str, ids: IdSourceRef, ) -> Result<StoreDir, StoreCreationError>

Create through the production builder, then close for a reopening fixture.

Source

pub fn create_store_dir( &self, id: StoreId, ids: &dyn IdSource, ) -> Result<StoreDir, DirectoryCreationError>

Publish a directory fixture without a database or member custody.

Source

pub fn join_network(&self, metered: bool)

The device moves to another usable network: a network report, as the platform’s would make (api.md E5).

Source

pub fn lose_network(&self)

The device loses its network: no report.

Source

pub fn network_cannot_tell(&self)

The platform fails to say what the device’s network is: coven can’t tell, and calls it metered, until the test says again.

Source

pub fn set_network_metered(&self, metered: bool)

The device’s network turns metered or unmetered: no report.

Source

pub fn keep_store_keys( &self, directory: &StoreDir, keys: &StoreKeyring, ) -> Result<(), KeyError>

Seed the simulated OS custody as if this installation had opened keys.

Source

pub fn save_device_keychain(&self, path: &Path) -> Result<(), KeyError>

Save this installation’s device-only keychain entries at path, replacing what is there: each store’s device id, store keys and member keys, which in_memory_with_saved_keychain loads. The person’s entries stay out.

Source

pub fn lose_storage_credentials(&self, store: StoreId) -> Result<(), KeyError>

Delete this installation’s storage credentials for store, as the person deleting the keychain entry by hand does. The recorded location stays: a handle opened afterwards reports no storage set up on this device, and setup connects that location again.

Source

pub fn fail_next_keychain_operation(&self)

Refuse the next keychain operation before changing any stored value.

Source§

impl Coven

Source

pub fn new( app_dir: PathBuf, keyring_service: &str, bugs: BugSinkRef, ) -> Result<Self, KeyError>

The stores under app_dir, their keys and secrets in the OS keychain under the service keyring_service, watching the platform’s network. The app creates app_dir; coven creates directories only inside it and never opens a directory above it, which Android refuses. No key is read here. A bug in work nobody waits for, in any store, goes to bugs, the app’s crash reporter (E15). An empty service name, or one containing NUL, fails with KeyError::InvalidServiceName; an OS keychain coven can’t reach fails with its KeyError.

Source

pub async fn storage_config( store_dir: &StoreDir, ) -> Result<Option<StorageConfig>, SyncError>

Read the saved storage location without opening the store or its custody. None means storage has never been set up; once set up, the location stays.

Source

pub async fn closed_sync_status( &self, store_dir: &StoreDir, ) -> Result<ClosedSyncStatus, CovenError>

A closed store’s sync state, last synced time and unsent work, read without opening it (E1, E5): the state opening shows before sync starts. It holds the store’s writer lock while it reads, since only that lock shows that no handle runs the store’s sync: an open handle, here or in another process, refuses it with StoreLockError::AlreadyOpen at once, and the app reads that handle. An instance closing in this process is waited for first, and an open of the store in this process meanwhile waits for this read. Whether this device holds the location’s credentials is read from the keychain, as opening reads it. A store whose replacement or deletion is unfinished is refused as opening refuses it, and one whose device entry the keychain doesn’t hold fails with DeviceKeyMissing.

Source

pub fn set_temporary_directory( directory: &Path, ) -> Result<(), TemporaryDirectoryError>

Keep SQLite’s temporary tables in directory, such as the app’s cache folder, for every store this process opens. An Android app calls this before opening its first store: SQLite finds no folder there by itself, and temporary tables that outgrow a connection’s cache fail without one. Elsewhere SQLite uses the system’s.

Source

pub async fn stores(&self) -> Result<Vec<ListedStore>, StoreListError>

Stores on this device, ordered by id, with their committed names. A store whose replacement record or name can’t be read is listed as Unreadable with why; a listing never substitutes an older name. A store whose replacement or deletion is unfinished lists with the work that must finish, so the app can offer to finish it; an unfinished first installation is not listed. First it finishes every deletion from the device that a cut call left under the directory’s deletion name, which no call holds (§19.3, E1); a failure there fails the listing with StoreListError::Deletion.

Source

pub fn store_dir(&self, id: &StoreId) -> StoreDir

Address a store without reading settings or acquiring the writer lock.

Source

pub fn builder(&self) -> CovenBuilder

Configure creating, opening, restoring or joining a store.

Source

pub async fn discard_store( &self, store_dir: &StoreDir, ) -> Result<(), StoreDeletionError>

Deletes a closed store from this device without opening it: this device’s own keychain entries for it, including every saved host secret, then its directory. The person’s saved restore code and S3 key stay for their next devices; they go only when the person leaves the store (§13.1). Unsent writes and files are lost, and this device stays registered with the store until it is removed; prefer CovenHandle::delete_store. Use this for a store that cannot open, or to finish a handle’s deletion that failed after closing. A store whose reset_device or restore_device stopped past its record is deleted whole: both installations, the replacement’s directory and record, and this device’s entries, which by then may name either device. Refused while a writer, read-only handle, file stream or a running replacement remains; storage is untouched. A handle of it in this process that is closing, or whose last clone was dropped, is waited for. Its first step renames the store’s directory, which hides the store and records the deletion: one that stops part way, a crash included, is finished by retrying, by the next stores(), or by a restore or join of the store (§19.3).

Source

pub async fn saved_restore_codes( &self, ) -> Result<Vec<SavedRestoreEntry>, BootstrapError>

The saved entries of this app’s keychain service, in iCloud Keychain on Apple and in this phone’s Block Store on Android, one per store, ordered by store id; empty when none are saved. An entry coven can’t restore from is listed as Unreadable, never omitted, so the person can forget it. A keychain read failure (the search, an entry’s bytes or an S3 key’s presence) fails the whole call, as does a restore-code account with no store id, KeyError::RestoreCodeStoreId. A keychain with neither iCloud Keychain nor Block Store fails with BootstrapError::SecureStorage(KeyError::Unsupported). Pass a readable entry to restore_from_saved_code, which reads its current code and key.

Source

pub async fn forget_saved_restore_code( &self, store: StoreId, ) -> Result<(), BootstrapError>

Delete the store’s saved S3 key, then its restore code: from iCloud Keychain, and so from every one of the person’s Apple devices, or from this phone’s Block Store, leaving other phones’ own (§13.1). Readable and unreadable entries alike; every keychain group’s copy goes. The store, its storage and every device’s copy stay; no store need be open and no provider connected. Absent entries succeed; after a failure part way the store is still listed, and calling again finishes. A later join, restore, reset or member-key replacement saves the entry again. A keychain with neither iCloud Keychain nor Block Store fails with BootstrapError::SecureStorage(KeyError::Unsupported).

Trait Implementations§

Source§

impl Clone for Coven

Source§

fn clone(&self) -> Coven

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

Auto Trait Implementations§

§

impl Freeze for Coven

§

impl !RefUnwindSafe for Coven

§

impl Send for Coven

§

impl Sync for Coven

§

impl Unpin for Coven

§

impl UnsafeUnpin for Coven

§

impl !UnwindSafe for Coven

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,