pub struct ServiceRegistry { /* private fields */ }Expand description
Holds the daemon’s registered services and routes control-socket envelopes
to them by name.
Implementations§
Source§impl ServiceRegistry
impl ServiceRegistry
Sourcepub fn register(&mut self, service: Arc<dyn DaemonService>)
pub fn register(&mut self, service: Arc<dyn DaemonService>)
Adds a service. Lookups match by DaemonService::name and the first
registration wins; a second service sharing a name would be dead code
for routing and would double-count in status/menu iteration, so it is
rejected with a warning rather than silently kept.
Sourcepub fn get(&self, name: &str) -> Option<&Arc<dyn DaemonService>>
pub fn get(&self, name: &str) -> Option<&Arc<dyn DaemonService>>
Returns the registered service with the given name, if any.
Sourcepub fn services(&self) -> &[Arc<dyn DaemonService>]
pub fn services(&self) -> &[Arc<dyn DaemonService>]
All registered services, in registration order.
Sourcepub async fn dispatch(
&self,
service: &str,
op: &str,
payload: Value,
) -> Result<Value>
pub async fn dispatch( &self, service: &str, op: &str, payload: Value, ) -> Result<Value>
Routes an operation to the named service, erroring if no such service is registered.
Sourcepub async fn statuses(&self) -> Vec<ServiceStatus>
pub async fn statuses(&self) -> Vec<ServiceStatus>
Collects status from every service, in registration order.
Sourcepub async fn shutdown_all(&self)
pub async fn shutdown_all(&self)
Gracefully shuts down every service, in registration order.
Trait Implementations§
Source§impl Clone for ServiceRegistry
impl Clone for ServiceRegistry
Source§fn clone(&self) -> ServiceRegistry
fn clone(&self) -> ServiceRegistry
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 Default for ServiceRegistry
impl Default for ServiceRegistry
Source§fn default() -> ServiceRegistry
fn default() -> ServiceRegistry
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !RefUnwindSafe for ServiceRegistry
impl !UnwindSafe for ServiceRegistry
impl Freeze for ServiceRegistry
impl Send for ServiceRegistry
impl Sync for ServiceRegistry
impl Unpin for ServiceRegistry
impl UnsafeUnpin for ServiceRegistry
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