ServiceRegistry

Struct ServiceRegistry 

Source
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

Source

pub fn new() -> Self

Create a new empty registry.

Source

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.

Source

pub fn service(&self, name: &str) -> Option<&ServiceEntry>

Look up a service by name.

Source

pub fn lookup_method( &self, service_name: &str, method_name: &str, ) -> Option<&MethodEntry>

Look up a method by service name and method name.

Source

pub fn method_by_id(&self, id: MethodId) -> Option<&MethodEntry>

Look up a method by its ID.

Source

pub fn resolve_method_id( &self, service_name: &str, method_name: &str, ) -> Option<MethodId>

Resolve a (service_name, method_name) pair to a MethodId.

Source

pub fn iter_services(&self) -> impl Iterator<Item = &ServiceEntry>

Iterate over all registered services.

Source

pub fn services(&self) -> impl Iterator<Item = &ServiceEntry>

Iterate over all registered services (alias for iter_services).

Source

pub fn service_by_id(&self, id: ServiceId) -> Option<&ServiceEntry>

Look up a service by its ID.

Source

pub fn service_count(&self) -> usize

Get the total number of registered services.

Source

pub fn method_count(&self) -> usize

Get the total number of registered methods (excluding control).

Source

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.

Source

pub fn with_global<F, R>(f: F) -> R
where F: FnOnce(&ServiceRegistry) -> R,

Access the global registry with a read lock.

§Example
use rapace_registry::ServiceRegistry;

ServiceRegistry::with_global(|registry| {
    for service in registry.services() {
        println!("Service: {}", service.name);
    }
});
Source

pub fn with_global_mut<F, R>(f: F) -> R
where F: FnOnce(&mut ServiceRegistry) -> R,

Modify the global registry with a write lock.

§Example
use rapace_registry::ServiceRegistry;

ServiceRegistry::with_global_mut(|registry| {
    let mut builder = registry.register_service("MyService", "docs");
    // ... add methods ...
    builder.finish();
});

Trait Implementations§

Source§

impl Debug for ServiceRegistry

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ServiceRegistry

Source§

fn default() -> ServiceRegistry

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.