pub struct EndpointMap<T: 'static> { /* private fields */ }Expand description
Maps endpoints to typed handlers for point-to-point messaging.
Provides O(1) lookup for registered endpoints and type-safe message dispatch.
Implementations§
Source§impl<T: 'static> EndpointMap<T>
impl<T: 'static> EndpointMap<T>
Sourcepub fn is_registered(&self, endpoint: MStr<Endpoint>) -> bool
pub fn is_registered(&self, endpoint: MStr<Endpoint>) -> bool
Returns whether an endpoint is registered.
Sourcepub fn register(&mut self, endpoint: MStr<Endpoint>, handler: TypedHandler<T>)
pub fn register(&mut self, endpoint: MStr<Endpoint>, handler: TypedHandler<T>)
Registers a handler at an endpoint.
If the endpoint already has a handler, it will be replaced.
Sourcepub fn deregister(&mut self, endpoint: MStr<Endpoint>)
pub fn deregister(&mut self, endpoint: MStr<Endpoint>)
Deregisters the handler at an endpoint.
Sourcepub fn get(&self, endpoint: MStr<Endpoint>) -> Option<&TypedHandler<T>>
pub fn get(&self, endpoint: MStr<Endpoint>) -> Option<&TypedHandler<T>>
Gets the handler registered at an endpoint.
Sourcepub fn send(&self, endpoint: MStr<Endpoint>, message: &T)
pub fn send(&self, endpoint: MStr<Endpoint>, message: &T)
Sends a message to an endpoint.
Logs an error if no handler is registered for the endpoint.
Trait Implementations§
Source§impl<T: Debug + 'static> Debug for EndpointMap<T>
impl<T: Debug + 'static> Debug for EndpointMap<T>
Auto Trait Implementations§
impl<T> !RefUnwindSafe for EndpointMap<T>
impl<T> !Send for EndpointMap<T>
impl<T> !Sync for EndpointMap<T>
impl<T> !UnwindSafe for EndpointMap<T>
impl<T> Freeze for EndpointMap<T>
impl<T> Unpin for EndpointMap<T>
impl<T> UnsafeUnpin for EndpointMap<T>
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