pub struct Follower<L: SharedUnlockDriver>(Arc<InnerFollower<L>>);Expand description
Tracks local state and follows authoritative lock updates from a leader.
Tuple Fields§
§0: Arc<InnerFollower<L>>Implementations§
Source§impl<L: SharedUnlockDriver + Send + Sync + 'static> Follower<L>
impl<L: SharedUnlockDriver + Send + Sync + 'static> Follower<L>
Sourcepub fn create(driver: L, ipc_client: Arc<dyn IpcClient>) -> Self
pub fn create(driver: L, ipc_client: Arc<dyn IpcClient>) -> Self
Creates a follower instance and starts sessions for all currently known users.
During startup, a StartSession message is sent per user so the leader can reconcile
initial lock state.
pub(crate) async fn start_sessions(&self)
Sourcepub async fn start(
&self,
cancellation_token: Option<CancellationToken>,
) -> Result<(), FollowerStartError>
pub async fn start( &self, cancellation_token: Option<CancellationToken>, ) -> Result<(), FollowerStartError>
Starts background tasks for IPC message handling and heartbeat timers.
Sourcepub async fn receive_message(
&self,
incoming_message: TypedIncomingMessage<LeaderMessage>,
) -> Result<(), ()>
pub async fn receive_message( &self, incoming_message: TypedIncomingMessage<LeaderMessage>, ) -> Result<(), ()>
Handles an authoritative message from the leader.
Lock state updates overwrite local state to keep follower and leader in sync. Heartbeat responses are forwarded to the heartbeat response handler.
Sourcepub async fn handle_device_event(&self, event: DeviceEvent) -> Result<(), ()>
pub async fn handle_device_event(&self, event: DeviceEvent) -> Result<(), ()>
Handles local device events and forwards them to the discovered leader.
Manual lock/unlock events are sent as lock state updates. Timer events send per-user heartbeats to keep the shared session active.
async fn send_message(&self, message: FollowerMessage, recipient: Endpoint)
Trait Implementations§
Auto Trait Implementations§
impl<L> Freeze for Follower<L>
impl<L> !RefUnwindSafe for Follower<L>
impl<L> Send for Follower<L>
impl<L> Sync for Follower<L>
impl<L> Unpin for Follower<L>
impl<L> UnsafeUnpin for Follower<L>
impl<L> !UnwindSafe for Follower<L>
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
Mutably borrows from an owned value. Read more
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
Create a new handle for an Arc value Read more
§unsafe fn clone_handle(handle: Handle) -> Handle
unsafe fn clone_handle(handle: Handle) -> Handle
Clone a handle Read more
§unsafe fn consume_handle(handle: Handle) -> Arc<T>
unsafe fn consume_handle(handle: Handle) -> Arc<T>
Consume a handle, getting back the initial
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>
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 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>
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