pub struct ActionRegistry { /* private fields */ }Expand description
Registry that maps action names to their handlers.
Thread-safe because every stored handler is Send + Sync.
Implementations§
Source§impl ActionRegistry
impl ActionRegistry
Sourcepub fn register(&mut self, handler: Box<dyn ActionHandler>)
pub fn register(&mut self, handler: Box<dyn ActionHandler>)
Register a handler, keyed by handler.name().
If a handler with the same name already exists it is replaced.
Sourcepub fn invoke(
&self,
entity: &HDict,
action: &str,
args: &HDict,
) -> Result<HGrid, String>
pub fn invoke( &self, entity: &HDict, action: &str, args: &HDict, ) -> Result<HGrid, String>
Dispatch an action invocation to the matching handler.
Returns Err with a descriptive message if no handler is registered
for the requested action name.
Sourcepub fn list_actions(&self) -> Vec<String>
pub fn list_actions(&self) -> Vec<String>
List all registered action names (in arbitrary order).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ActionRegistry
impl !RefUnwindSafe for ActionRegistry
impl Send for ActionRegistry
impl Sync for ActionRegistry
impl Unpin for ActionRegistry
impl UnsafeUnpin for ActionRegistry
impl !UnwindSafe for ActionRegistry
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more