pub struct TypedDenseOperationTable<State, Context, Error> { /* private fields */ }Expand description
Fixed 256-slot selector table for application-specific state machines.
Every slot is initialized with the caller-provided fallback operation. The
hot path is therefore a selector-indexed function-pointer call without an
Option lookup. This is still an indirect branch at the CPU level.
Implementations§
Source§impl<State, Context, Error> TypedDenseOperationTable<State, Context, Error>
impl<State, Context, Error> TypedDenseOperationTable<State, Context, Error>
Sourcepub fn new(fallback: TypedDenseOpFn<State, Context, Error>) -> Self
pub fn new(fallback: TypedDenseOpFn<State, Context, Error>) -> Self
Create a table with all selectors bound to fallback.
Sourcepub fn register(
&mut self,
selector: u8,
operation: TypedDenseOpFn<State, Context, Error>,
)
pub fn register( &mut self, selector: u8, operation: TypedDenseOpFn<State, Context, Error>, )
Register an application operation at a raw byte selector.
Sourcepub fn register_word(
&mut self,
selector: SelectorWord,
operation: TypedDenseOpFn<State, Context, Error>,
)
pub fn register_word( &mut self, selector: SelectorWord, operation: TypedDenseOpFn<State, Context, Error>, )
Register using the function byte of a 4/4/8 selector word.
Sourcepub fn execute(
&self,
selector: u8,
state: &mut State,
context: &Context,
) -> Result<(), Error>
pub fn execute( &self, selector: u8, state: &mut State, context: &Context, ) -> Result<(), Error>
Execute by raw selector.
Sourcepub fn execute_word(
&self,
selector: SelectorWord,
state: &mut State,
context: &Context,
) -> Result<(), Error>
pub fn execute_word( &self, selector: SelectorWord, state: &mut State, context: &Context, ) -> Result<(), Error>
Execute using the function byte of a selector word.
Trait Implementations§
Source§impl<State, Context, Error> Clone for TypedDenseOperationTable<State, Context, Error>
impl<State, Context, Error> Clone for TypedDenseOperationTable<State, Context, Error>
Auto Trait Implementations§
impl<State, Context, Error> Freeze for TypedDenseOperationTable<State, Context, Error>
impl<State, Context, Error> RefUnwindSafe for TypedDenseOperationTable<State, Context, Error>
impl<State, Context, Error> Send for TypedDenseOperationTable<State, Context, Error>
impl<State, Context, Error> Sync for TypedDenseOperationTable<State, Context, Error>
impl<State, Context, Error> Unpin for TypedDenseOperationTable<State, Context, Error>
impl<State, Context, Error> UnsafeUnpin for TypedDenseOperationTable<State, Context, Error>
impl<State, Context, Error> UnwindSafe for TypedDenseOperationTable<State, Context, Error>
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