pub struct SharedUnlockPeer<D: SharedUnlockDriver>(Arc<InnerPeer<D>>);Expand description
One participant in the shared unlock protocol.
Tuple Fields§
§0: Arc<InnerPeer<D>>Implementations§
Sourcepub fn create(driver: D, ipc_client: Arc<dyn IpcClient>) -> Self
pub fn create(driver: D, ipc_client: Arc<dyn IpcClient>) -> Self
Creates a peer. Nothing is sent until SharedUnlockPeer::start is called.
Sourcepub fn create_for_test(
driver: D,
ipc_client: Arc<dyn IpcClient>,
sync_interval: Duration,
vault_timeout_grace_period: Duration,
peer_stale_after: Duration,
) -> Self
pub fn create_for_test( driver: D, ipc_client: Arc<dyn IpcClient>, sync_interval: Duration, vault_timeout_grace_period: Duration, peer_stale_after: Duration, ) -> Self
Creates a peer that syncs on the given timings rather than the production ones, so tests do
not have to wait out a 5s interval. Compiled only for tests and under test-support.
fn create_with_timing( driver: D, ipc_client: Arc<dyn IpcClient>, timing: SharedUnlockTiming, ) -> Self
Sourcepub fn set_destinations(
&self,
user_id: UserId,
destinations: Vec<SharedUnlockClient>,
)
pub fn set_destinations( &self, user_id: UserId, destinations: Vec<SharedUnlockClient>, )
Sets which clients this peer shares one user’s unlock state with, in both directions: a client that is not in the set is never synced that user, and that user’s syncs from it are dropped on arrival. Replaces any previous set for the user.
Every user defaults to no client at all — a peer neither sends nor accepts anything for a user until this is called for it.
fn is_destination(&self, user_id: UserId, endpoint: &Endpoint) -> bool
Sourcepub async fn start(
&self,
cancellation_token: Option<CancellationToken>,
) -> Result<(), PeerStartError>
pub async fn start( &self, cancellation_token: Option<CancellationToken>, ) -> Result<(), PeerStartError>
Starts the receive loop and the sync timer, then announces this peer’s state once so it does not have to wait a full interval to be discovered.
Sourcepub async fn receive_message(
&self,
incoming_message: TypedIncomingMessage<SharedUnlockSync>,
) -> Result<(), ()>
pub async fn receive_message( &self, incoming_message: TypedIncomingMessage<SharedUnlockSync>, ) -> Result<(), ()>
Handles a sync from another peer.
Sourcepub async fn handle_device_event(&self, event: DeviceEvent) -> Result<(), ()>
pub async fn handle_device_event(&self, event: DeviceEvent) -> Result<(), ()>
Records a lock state change made on this device and syncs it to every peer immediately.
Sourceasync fn apply_remote_state(
&self,
user_id: UserId,
remote: TimestampedLockState,
) -> Result<(), ()>
async fn apply_remote_state( &self, user_id: UserId, remote: TimestampedLockState, ) -> Result<(), ()>
Applies a peer’s state if it is newer than what this device has recorded.
Sourceasync fn sync_all_users(&self)
async fn sync_all_users(&self)
Sends this peer’s state for every logged-in user to every peer it syncs with.
async fn sync_user(&self, user_id: UserId)
Sourceasync fn sync_all_users_to(&self, target: &SyncTarget)
async fn sync_all_users_to(&self, target: &SyncTarget)
Sends this peer’s state for every logged-in user to one specific peer.
async fn sync_user_to(&self, user_id: UserId, target: &SyncTarget)
Sourceasync fn may_sync_user_to(&self, user_id: UserId, target: &SyncTarget) -> bool
async fn may_sync_user_to(&self, user_id: UserId, target: &SyncTarget) -> bool
Whether a user’s state may be sent to a peer.
The peer must be among the user’s configured destinations.
A web peer is additionally entitled only to the users whose vault URL is the
origin it was validated
against — the same rule SharedUnlockPeer::receive_message applies to incoming syncs,
applied outbound so a page served by one vault is never handed another vault’s key material.
A web peer with no recorded origin fails closed.
Sourceasync fn sync_targets(&self) -> Vec<SyncTarget>
async fn sync_targets(&self) -> Vec<SyncTarget>
This peer’s leader, if it has one, plus every peer that syncs to it.
async fn send_message(&self, message: SharedUnlockSync, recipient: Endpoint)
Sourcepub fn recorded_changed_at(&self, user_id: UserId) -> Option<u64>
pub fn recorded_changed_at(&self, user_id: UserId) -> Option<u64>
The date this peer has recorded for a user, for tests that assert two peers converged on one
date and not merely on one state. Compiled only for tests and under test-support.
fn recorded_state(&self, user_id: UserId) -> Option<TimestampedLockState>
Sourcefn advertised_state(&self, user_id: UserId) -> TimestampedLockState
fn advertised_state(&self, user_id: UserId) -> TimestampedLockState
The state to advertise for a user: the recorded one, or a presence marker.
Sourcefn record_remote_state(&self, user_id: UserId, state: TimestampedLockState)
fn record_remote_state(&self, user_id: UserId, state: TimestampedLockState)
Records a state reported by a peer, if it still supersedes what is recorded.
Sourcefn record_local_state(&self, user_id: UserId, lock_state: LockState)
fn record_local_state(&self, user_id: UserId, lock_state: LockState)
Records a change made on this device.
Trait Implementations§
Auto Trait Implementations§
Blanket Implementations§
§impl<T> AnySync for T
impl<T> AnySync for T
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> CompatExt for T
impl<T> CompatExt for T
§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
§fn new_handle(value: Arc<T>) -> Handle
fn new_handle(value: Arc<T>) -> Handle
§unsafe fn clone_handle(handle: Handle) -> Handle
unsafe fn clone_handle(handle: Handle) -> Handle
§unsafe fn consume_handle(handle: Handle) -> Arc<T>
unsafe fn consume_handle(handle: Handle) -> Arc<T>
Arc<> Read more§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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