Skip to main content

RestoreCodes

Struct RestoreCodes 

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

Owns code generation and credential changes for one open handle, for its whole lifetime: connected or not, one change runs at a time, and a read waits for the change in flight. A change that needs the connection takes its sequence owner as an argument. Closing waits for updates holding the lock, even when their app futures were dropped.

Implementations§

Source§

impl RestoreCodes

Source

pub async fn location(&self) -> Result<Option<StorageConfig>, SyncError>

The recorded location survives losing this device’s credentials.

Source

pub async fn record_labels( &self, location: &StorageConfig, ) -> Result<(), SyncError>

Record location, the recorded location as a connection made from it just labelled it (§20.2), and write it to the sync status row, which an app’s live query reads it from (api.md E4). Writes only when its labels changed.

Source

pub fn new( directory: StoreDir, database: StoreDatabase, identity: Arc<KeySession<MemberIdentity>>, credentials: Arc<DeviceCredentials>, ) -> Self

Compose at the facade’s opening boundary. The settings and credentials are also the narrow persisted connection contract used by storage setup.

Source

pub fn provider_auth(&self, credentials: StorageCredentials) -> ProviderAuth

How a connection reaches storage with these committed credentials: a rejected OAuth token refreshes in this installation’s device custody, which takes no lock held by credential changes (§20.2).

Source

pub async fn restore_code(&self) -> Result<String, SyncError>

Encode this member’s stable id and current private pair, store id and storage location only. The pair is the held one the applied history binds now; without it the call reports MemberKeysReplaced rather than exporting a retired pair (§13.1).

Source

pub async fn replace_member_keys( &self, sync: Arc<SequenceSync>, ) -> Result<SecretText, SyncError>

Replace this member’s pair on sync, the connection’s sequence owner, and return the code for that exact result. The change holds this owner from the call on, so credential changes, reads and settled wait for it, even once its caller stops waiting.

Source

pub async fn s3_connection( &self, key: S3Credentials, ) -> Result<ConnectionCredentials, SyncError>

The connection credentials for the S3 key key at the recorded location, for a connection that uses it before custody holds it. A member whose removal applied gets Removed (§14.1).

Source

pub async fn use_access_key( &self, sync: Arc<SequenceSync>, live: Option<Arc<SequenceSync>>, key: S3Credentials, ) -> Result<Option<String>, SyncError>

Use the S3 key the person made in the provider’s console, once its provider check passed, without changing identity, location or code (§14.3): journal the entry that records it as this member’s access on sync, whose connection signs with the key; take it in custody and on live, the owner of the store’s connection when that is another; and claim the entry with it. Answers the key id the record named before, when the call has an entry. A member whose removal applied gets Removed (§14.1). The change holds this owner as replace_member_keys does.

Source

pub async fn connection( &self, ) -> Result<Option<ConnectionCredentials>, SyncError>

Read committed provider data without exposing custody or a connection.

Source

pub async fn prepare_setup( &self, data: ConnectionCredentials, sign_in: Option<Arc<SessionSignIn>>, ) -> Result<(StorageCommit, SecretText), SyncError>

Reserve the credential owner until remote setup either commits or fails. The returned commit includes the saved restore code and location, and its compensation remains available until store keys and the origin are applied. An OAuth setup commits sign_in’s current tokens, which then refresh in device custody; a rollback holds them in the session again. Reconnecting with device custody keeps its current tokens, including any refresh.

Source

pub async fn settled(&self)

Wait for a credential change in flight, even one whose caller stopped waiting: a connection closes only after the change it runs.

Source

pub async fn close(&self)

Finish the current update, then release custody and connection owners. Updates that have not acquired the lock receive StoreClosed.

Source

pub async fn while_open( &self, operation: &'static str, work: impl FnOnce(&StoreDir) -> Result<(), FileError> + Send + 'static, ) -> Result<(), SyncError>

Run work, named operation, on the store’s directory while this owner stays open: closing waits for it, so the store’s writer lock isn’t released under a write of its files, and a closed store refuses it with StoreClosed.

Trait Implementations§

Source§

impl Clone for RestoreCodes

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more

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
§

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,

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
§

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

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: Sized + 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: Sized + 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
§

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

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

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

fn try_from(value: U) -> Result<T, !>

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