pub struct QueryHandlerRegistry { /* private fields */ }Expand description
The QueryHandlerRegistry manages associations between query types and their handlers.
It provides a type-safe way to register handlers for specific query types and retrieve them when needed for data query operations.
Implementations§
Source§impl QueryHandlerRegistry
Implementation for QueryHandlerRegistry.
impl QueryHandlerRegistry
Implementation for QueryHandlerRegistry.
Sourcepub fn register<Q: Query>(&mut self, handler: impl QueryHandler<Q> + 'static)
pub fn register<Q: Query>(&mut self, handler: impl QueryHandler<Q> + 'static)
Registers a query handler for a specific query type.
§Arguments
handler- The handler implementation to register for query typeQ.
When queries of type Q are dispatched, the registered handler will be used.
§Example
let mut registry = QueryHandlerRegistry::new();
registry.register(FindProductQueryHandler);Sourcepub fn get_handler<Q: Query>(&self) -> Option<Box<dyn QueryHandler<Q>>>
pub fn get_handler<Q: Query>(&self) -> Option<Box<dyn QueryHandler<Q>>>
Retrieves the handler for a specific query type.
§Returns
An Option containing the query handler if one is registered for type Q,
or None if no handler is known for this query type.
§Example
let mut registry = QueryHandlerRegistry::new();
registry.register(FindProductQueryHandler);
let handler = registry.get_handler::<FindProductQuery>();
assert!(handler.is_some());Trait Implementations§
Source§impl Debug for QueryHandlerRegistry
Debug implementation for QueryHandlerRegistry
impl Debug for QueryHandlerRegistry
Debug implementation for QueryHandlerRegistry
Source§impl Default for QueryHandlerRegistry
impl Default for QueryHandlerRegistry
Source§fn default() -> QueryHandlerRegistry
fn default() -> QueryHandlerRegistry
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !RefUnwindSafe for QueryHandlerRegistry
impl !UnwindSafe for QueryHandlerRegistry
impl Freeze for QueryHandlerRegistry
impl Send for QueryHandlerRegistry
impl Sync for QueryHandlerRegistry
impl Unpin for QueryHandlerRegistry
impl UnsafeUnpin for QueryHandlerRegistry
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