Hello,
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 https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=4afd678a1e7d57d925a2f5b8ebbbabd0
I will be glad for some suggestion or help with it