pub struct CommandRegistry<T: ICommandInfo> { /* private fields */ }Expand description
Map request types to their handlers.
Implementations§
Source§impl<T: ICommandInfo> CommandRegistry<T>
impl<T: ICommandInfo> CommandRegistry<T>
Sourcepub fn new() -> Self
pub fn new() -> Self
Create an empty CommandRegistry.
Sourcepub fn register<R: Executable + Send + Sync + 'static, H: Execute<R, R::Response, R::ExecutionError>>(
&mut self,
handler: Arc<H>,
)
pub fn register<R: Executable + Send + Sync + 'static, H: Execute<R, R::Response, R::ExecutionError>>( &mut self, handler: Arc<H>, )
Register a handler for a request type.
Sourcepub fn resolve<R: Executable + Send + Sync + 'static>(
&self,
request: R,
) -> Result<T::Command, Report<QueueError>>
pub fn resolve<R: Executable + Send + Sync + 'static>( &self, request: R, ) -> Result<T::Command, Report<QueueError>>
Resolve a request into a command by matching it to a registered handler.
Trait Implementations§
Source§impl<T: RegisterHandlers + 'static> FromServicesAsync for CommandRegistry<T>
impl<T: RegisterHandlers + 'static> FromServicesAsync for CommandRegistry<T>
Source§type Error = ResolveError
type Error = ResolveError
Error type returned by
FromServicesAsync::from_services_async.Source§async fn from_services_async(
services: &ServiceProvider,
) -> Result<Self, Report<Self::Error>>
async fn from_services_async( services: &ServiceProvider, ) -> Result<Self, Report<Self::Error>>
Create an instance asynchronously by resolving dependencies from the
ServiceProvider.Auto Trait Implementations§
impl<T> Freeze for CommandRegistry<T>
impl<T> RefUnwindSafe for CommandRegistry<T>
impl<T> Send for CommandRegistry<T>
impl<T> Sync for CommandRegistry<T>
impl<T> Unpin for CommandRegistry<T>
impl<T> UnsafeUnpin for CommandRegistry<T>
impl<T> UnwindSafe for CommandRegistry<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