pub struct ModuleFactory { /* private fields */ }Expand description
Registry that maps module type names to constructors.
Implementations§
Source§impl ModuleFactory
impl ModuleFactory
Sourcepub fn register(&mut self, ctor: impl ModuleConstructor + 'static)
pub fn register(&mut self, ctor: impl ModuleConstructor + 'static)
Adds a typed constructor to the registry, keyed by its type name.
Sourcepub fn register_fn(
&mut self,
type_name: impl Into<String>,
drain: Drain,
make_handler: impl Fn(&str, &HashMap<String, ParamValue>, &ActorRef<CommandEnum>) -> Box<dyn FnMut(CommandEnum) + 'static> + Send + Sync + 'static,
)
pub fn register_fn( &mut self, type_name: impl Into<String>, drain: Drain, make_handler: impl Fn(&str, &HashMap<String, ParamValue>, &ActorRef<CommandEnum>) -> Box<dyn FnMut(CommandEnum) + 'static> + Send + Sync + 'static, )
Register a closure-based constructor (handler: !Send).
make_handler receives module params and the graph handle, and returns
the message handler closure. The factory calls it inside the drain thread,
so the handler does not need Send.
Sourcepub fn register_fn_send(
&mut self,
type_name: impl Into<String>,
drain: Drain,
make_handler: impl Fn(&str, &HashMap<String, ParamValue>, &ActorRef<CommandEnum>) -> Box<dyn FnMut(CommandEnum) + Send + 'static> + Send + Sync + 'static,
)
pub fn register_fn_send( &mut self, type_name: impl Into<String>, drain: Drain, make_handler: impl Fn(&str, &HashMap<String, ParamValue>, &ActorRef<CommandEnum>) -> Box<dyn FnMut(CommandEnum) + Send + 'static> + Send + Sync + 'static, )
Register a closure-based constructor (handler: Send, for Drain::TokioTask).
The returned handler must be Send so it can be stored in a tokio future.
Sourcepub fn construct(
&self,
module: &ModuleDef,
automaton_defs: &[AutomatonDef],
system: &Arc<ActorSystem>,
graph_ref: &ActorRef<CommandEnum>,
) -> Result<ActorRef<CommandEnum>, ModuleError>
pub fn construct( &self, module: &ModuleDef, automaton_defs: &[AutomatonDef], system: &Arc<ActorSystem>, graph_ref: &ActorRef<CommandEnum>, ) -> Result<ActorRef<CommandEnum>, ModuleError>
Looks up a type name and constructs the corresponding module actor.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ModuleFactory
impl !RefUnwindSafe for ModuleFactory
impl Send for ModuleFactory
impl Sync for ModuleFactory
impl Unpin for ModuleFactory
impl UnsafeUnpin for ModuleFactory
impl !UnwindSafe for ModuleFactory
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