How to handle in HashMap generic box trait

while implementing one of the architecture patterns called CQRS for backend I want to move someplace when I could initialize handler related for some type. While implementing trait with two generic values I have error messages:

handlers.insert(String::from(type_name::<CreateLibrary>()), Box::new(LibraryCommandHandler{})); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait modules::common::command_handler::CommandHandler<dyn modules::library::domain::create_library::Command, std::result::Result<std::string::String, ()>> is not implemented for modules::library::domain::command_handler::LibraryCommandHandler
And second error message:
error: the handlemethod cannot be invoked on a trait object

and my code looks like
I will be glad for some suggestion or help with it

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.