pub struct FnAdapter<W: Workflow, A, D>where
A: Fn(&FormatVersion) -> bool + Send + Sync + 'static,
D: Fn(&dyn Any, &FormatVersion) -> Result<W::Command, EngineError> + Send + Sync + 'static,{ /* private fields */ }Expand description
A simple function-based adapter constructed via
FnAdapter::new.
Use this for lightweight adapters that do not need to carry state.
§Example
ⓘ
use mako_engine::message_adapter::{AdapterRegistry, FnAdapter};
let mut registry: AdapterRegistry<MyWorkflow> = AdapterRegistry::new();
registry.register(FnAdapter::new(
|fv| fv.as_str() == "FV2025-10-01",
|raw, _fv| {
// cast raw and construct command
Ok(MyCommand::Received)
},
));Implementations§
Trait Implementations§
Source§impl<W: Workflow, A, D> MessageAdapter<W> for FnAdapter<W, A, D>where
A: Fn(&FormatVersion) -> bool + Send + Sync + 'static,
D: Fn(&dyn Any, &FormatVersion) -> Result<W::Command, EngineError> + Send + Sync + 'static,
impl<W: Workflow, A, D> MessageAdapter<W> for FnAdapter<W, A, D>where
A: Fn(&FormatVersion) -> bool + Send + Sync + 'static,
D: Fn(&dyn Any, &FormatVersion) -> Result<W::Command, EngineError> + Send + Sync + 'static,
Source§fn accepts_format_version(&self, fv: &FormatVersion) -> bool
fn accepts_format_version(&self, fv: &FormatVersion) -> bool
Source§fn adapt(
&self,
raw: &dyn Any,
fv: &FormatVersion,
) -> Result<W::Command, EngineError>
fn adapt( &self, raw: &dyn Any, fv: &FormatVersion, ) -> Result<W::Command, EngineError>
Translate a raw parsed message into a domain command. Read more
Auto Trait Implementations§
impl<W, A, D> Freeze for FnAdapter<W, A, D>
impl<W, A, D> RefUnwindSafe for FnAdapter<W, A, D>
impl<W, A, D> Send for FnAdapter<W, A, D>
impl<W, A, D> Sync for FnAdapter<W, A, D>
impl<W, A, D> Unpin for FnAdapter<W, A, D>
impl<W, A, D> UnsafeUnpin for FnAdapter<W, A, D>where
A: UnsafeUnpin,
D: UnsafeUnpin,
impl<W, A, D> UnwindSafe for FnAdapter<W, A, D>
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