Skip to main content

DispatchTable

Struct DispatchTable 

Source
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>

Source

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.

Source

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.

Source

pub fn machine(&self) -> &M

Returns a shared reference to the underlying machine.

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.