pub struct ServiceRegistry { /* private fields */ }Expand description
A registry of RPC services and their methods.
The registry stores services/methods keyed by their on-wire method IDs and provides
lookup by name or by MethodId.
Implementations§
Source§impl ServiceRegistry
impl ServiceRegistry
Sourcepub fn register_service(
&mut self,
name: &'static str,
doc: impl Into<String>,
) -> ServiceBuilder<'_>
pub fn register_service( &mut self, name: &'static str, doc: impl Into<String>, ) -> ServiceBuilder<'_>
Register a new service with the given name and documentation.
Returns a builder for adding methods to the service.
Sourcepub fn service(&self, name: &str) -> Option<&ServiceEntry>
pub fn service(&self, name: &str) -> Option<&ServiceEntry>
Look up a service by name.
Sourcepub fn lookup_method(
&self,
service_name: &str,
method_name: &str,
) -> Option<&MethodEntry>
pub fn lookup_method( &self, service_name: &str, method_name: &str, ) -> Option<&MethodEntry>
Look up a method by service name and method name.
Sourcepub fn method_by_id(&self, id: MethodId) -> Option<&MethodEntry>
pub fn method_by_id(&self, id: MethodId) -> Option<&MethodEntry>
Look up a method by its ID.
Sourcepub fn resolve_method_id(
&self,
service_name: &str,
method_name: &str,
) -> Option<MethodId>
pub fn resolve_method_id( &self, service_name: &str, method_name: &str, ) -> Option<MethodId>
Resolve a (service_name, method_name) pair to a MethodId.
Sourcepub fn iter_services(&self) -> impl Iterator<Item = &ServiceEntry>
pub fn iter_services(&self) -> impl Iterator<Item = &ServiceEntry>
Iterate over all registered services.
Sourcepub fn services(&self) -> impl Iterator<Item = &ServiceEntry>
pub fn services(&self) -> impl Iterator<Item = &ServiceEntry>
Iterate over all registered services (alias for iter_services).
Sourcepub fn service_by_id(&self, id: ServiceId) -> Option<&ServiceEntry>
pub fn service_by_id(&self, id: ServiceId) -> Option<&ServiceEntry>
Look up a service by its ID.
Sourcepub fn service_count(&self) -> usize
pub fn service_count(&self) -> usize
Get the total number of registered services.
Sourcepub fn method_count(&self) -> usize
pub fn method_count(&self) -> usize
Get the total number of registered methods (excluding control).
Sourcepub fn global() -> &'static RwLock<ServiceRegistry>
pub fn global() -> &'static RwLock<ServiceRegistry>
Get a reference to the global service registry.
Use this when you need direct access to the RwLock for complex operations.
For simple read/write access, prefer with_global or with_global_mut.