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
impl RestoreCodes
Sourcepub async fn location(&self) -> Result<Option<StorageConfig>, SyncError>
pub async fn location(&self) -> Result<Option<StorageConfig>, SyncError>
The recorded location survives losing this device’s credentials.
Sourcepub async fn record_labels(
&self,
location: &StorageConfig,
) -> Result<(), SyncError>
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.
Sourcepub fn new(
directory: StoreDir,
database: StoreDatabase,
identity: Arc<KeySession<MemberIdentity>>,
credentials: Arc<DeviceCredentials>,
) -> Self
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.
Sourcepub fn provider_auth(&self, credentials: StorageCredentials) -> ProviderAuth
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).
Sourcepub async fn restore_code(&self) -> Result<String, SyncError>
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).
Sourcepub async fn replace_member_keys(
&self,
sync: Arc<SequenceSync>,
) -> Result<SecretText, SyncError>
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.
Sourcepub async fn s3_connection(
&self,
key: S3Credentials,
) -> Result<ConnectionCredentials, SyncError>
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).
Sourcepub async fn use_access_key(
&self,
sync: Arc<SequenceSync>,
live: Option<Arc<SequenceSync>>,
key: S3Credentials,
) -> Result<Option<String>, SyncError>
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.
Sourcepub async fn connection(
&self,
) -> Result<Option<ConnectionCredentials>, SyncError>
pub async fn connection( &self, ) -> Result<Option<ConnectionCredentials>, SyncError>
Read committed provider data without exposing custody or a connection.
Sourcepub async fn prepare_setup(
&self,
data: ConnectionCredentials,
sign_in: Option<Arc<SessionSignIn>>,
) -> Result<(StorageCommit, SecretText), SyncError>
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.
Sourcepub async fn settled(&self)
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.
Sourcepub async fn close(&self)
pub async fn close(&self)
Finish the current update, then release custody and connection owners. Updates that have not acquired the lock receive StoreClosed.
Sourcepub async fn while_open(
&self,
operation: &'static str,
work: impl FnOnce(&StoreDir) -> Result<(), FileError> + Send + 'static,
) -> Result<(), SyncError>
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§
Auto Trait Implementations§
impl !RefUnwindSafe for RestoreCodes
impl !UnwindSafe for RestoreCodes
impl Freeze for RestoreCodes
impl Send for RestoreCodes
impl Sync for RestoreCodes
impl Unpin for RestoreCodes
impl UnsafeUnpin for RestoreCodes
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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