pub struct DeviceRegistry {
pub profile: Arc<dyn CsiProfile>,
/* private fields */
}Expand description
Runtime registry of attached devices, keyed by DeviceHandle::id.
Uses a std::sync::RwLock: every critical section clones an Arc out and
drops the guard immediately — the lock is never held across an .await, so
an async lock would only add cost. The supervisor is the only writer.
Fields§
§profile: Arc<dyn CsiProfile>Capability profile handed to every device spawned by this registry.
Implementations§
Source§impl DeviceRegistry
impl DeviceRegistry
Sourcepub fn with_profile(profile: Arc<dyn CsiProfile>) -> Self
pub fn with_profile(profile: Arc<dyn CsiProfile>) -> Self
A registry whose spawned devices carry the given capability profile.
Sourcepub fn get(&self, id: &str) -> Option<Arc<DeviceHandle>>
pub fn get(&self, id: &str) -> Option<Arc<DeviceHandle>>
Look up a device by id, returning an owned Arc clone.
Sourcepub fn insert(&self, dev: Arc<DeviceHandle>) -> Option<Arc<DeviceHandle>>
pub fn insert(&self, dev: Arc<DeviceHandle>) -> Option<Arc<DeviceHandle>>
Insert a newly discovered device. Returns the previous handle for this id, if any.
Sourcepub fn remove(&self, id: &str) -> Option<Arc<DeviceHandle>>
pub fn remove(&self, id: &str) -> Option<Arc<DeviceHandle>>
Remove a device by id, returning its handle if present.
Sourcepub fn snapshot(&self) -> Vec<Arc<DeviceHandle>>
pub fn snapshot(&self) -> Vec<Arc<DeviceHandle>>
Snapshot of all current devices, sorted by id for stable listings.
Sourcepub fn attach(&self, spec: DeviceAttachSpec) -> Arc<DeviceHandle>
pub fn attach(&self, spec: DeviceAttachSpec) -> Arc<DeviceHandle>
Spawn a serial worker for spec and register it. Returns the new handle.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for DeviceRegistry
impl !RefUnwindSafe for DeviceRegistry
impl !UnwindSafe for DeviceRegistry
impl Send for DeviceRegistry
impl Sync for DeviceRegistry
impl Unpin for DeviceRegistry
impl UnsafeUnpin 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