pub struct DispatchTable<'a, M, Raw, R> { /* private fields */ }Expand description
Routes a runtime event ID to one of a contiguous set of typed handlers.
Each handler is responsible for translating the raw event into the generated event enum expected by its state machine.
Implementations§
Source§impl<'a, M, Raw, R> DispatchTable<'a, M, Raw, R>
impl<'a, M, Raw, R> DispatchTable<'a, M, Raw, R>
Sourcepub const fn new(
machine: &'a mut M,
first_id: usize,
handlers: &'a [fn(&mut M, &Raw) -> R],
) -> Self
pub const fn new( machine: &'a mut M, first_id: usize, handlers: &'a [fn(&mut M, &Raw) -> R], ) -> Self
Creates a table whose first handler corresponds to first_id.
Sourcepub fn dispatch(&mut self, raw: &Raw, id: usize) -> Option<R>
pub fn dispatch(&mut self, raw: &Raw, id: usize) -> Option<R>
Dispatches raw through the handler associated with id.
Returns None when the ID is outside the table’s contiguous range.
Sourcepub fn machine_mut(&mut self) -> &mut M
pub fn machine_mut(&mut self) -> &mut M
Returns a mutable reference to the underlying machine.
Auto Trait Implementations§
impl<'a, M, Raw, R> !UnwindSafe for DispatchTable<'a, M, Raw, R>
impl<'a, M, Raw, R> Freeze for DispatchTable<'a, M, Raw, R>
impl<'a, M, Raw, R> RefUnwindSafe for DispatchTable<'a, M, Raw, R>where
M: RefUnwindSafe,
impl<'a, M, Raw, R> Send for DispatchTable<'a, M, Raw, R>where
M: Send,
impl<'a, M, Raw, R> Sync for DispatchTable<'a, M, Raw, R>where
M: Sync,
impl<'a, M, Raw, R> Unpin for DispatchTable<'a, M, Raw, R>
impl<'a, M, Raw, R> UnsafeUnpin for DispatchTable<'a, M, Raw, R>
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