pub struct DeviceRegistry { /* private fields */ }Expand description
Thread-safe set of attached devices.
Mirrors crate::session::SessionStore: an RwLock<HashMap<_, _>> rather
than a concurrent-map dependency, since reads dominate and the map is small.
Implementations§
Source§impl DeviceRegistry
impl DeviceRegistry
Sourcepub fn attach(
&self,
id: impl Into<String>,
label: Option<String>,
) -> DeviceHandles
pub fn attach( &self, id: impl Into<String>, label: Option<String>, ) -> DeviceHandles
Attach a device under id, replacing any previous entry for it.
Sourcepub fn detach(&self, id: &str) -> bool
pub fn detach(&self, id: &str) -> bool
Detach a device, e.g. when its control connection closes.
Sourcepub fn touch(&self, id: &str) -> bool
pub fn touch(&self, id: &str) -> bool
Record a heartbeat. Returns false if the device is not attached.
Sourcepub fn list(&self) -> Vec<DeviceSummary>
pub fn list(&self) -> Vec<DeviceSummary>
Snapshot of every attached device, newest attachment first.
Sourcepub fn evict_stale(&self, timeout: Duration) -> Vec<String>
pub fn evict_stale(&self, timeout: Duration) -> Vec<String>
Drop devices that have not been heard from within timeout.
A half-open connection (the peer vanished without a close frame) is indistinguishable from an idle one at the socket level, so staleness is judged from heartbeats.
Trait Implementations§
Source§impl Clone for DeviceRegistry
impl Clone for DeviceRegistry
Source§fn clone(&self) -> DeviceRegistry
fn clone(&self) -> DeviceRegistry
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DeviceRegistry
impl Debug for DeviceRegistry
Source§impl Default for DeviceRegistry
impl Default for DeviceRegistry
Source§fn default() -> DeviceRegistry
fn default() -> DeviceRegistry
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for DeviceRegistry
impl RefUnwindSafe for DeviceRegistry
impl Send for DeviceRegistry
impl Sync for DeviceRegistry
impl Unpin for DeviceRegistry
impl UnsafeUnpin for DeviceRegistry
impl UnwindSafe for DeviceRegistry
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.