pub struct RustFnInProcessSpawnerFactory { /* private fields */ }Expand description
Factory for AgentKind::RustFn. At build time it looks the fn_id
up in its internal registry and returns an InProcSpawner with the
Rust closure WorkerFn registered under agent_name.
Naming convention: <WorkerIMPL><AdapterType>SpawnerFactory (RustFn
worker on InProcess adapter). Sibling to
LuaInProcessSpawnerFactory — the Lua-worker half of the same
split.
Spec shape:
{ "fn_id": "echo" } // Rust closure id pre-registered with the factoryImplementations§
Source§impl RustFnInProcessSpawnerFactory
impl RustFnInProcessSpawnerFactory
Sourcepub fn register_fn<F, Fut>(self, fn_id: impl Into<String>, f: F) -> Selfwhere
F: Fn(WorkerInvocation) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<WorkerResult, WorkerError>> + Send + 'static,
pub fn register_fn<F, Fut>(self, fn_id: impl Into<String>, f: F) -> Selfwhere
F: Fn(WorkerInvocation) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<WorkerResult, WorkerError>> + Send + 'static,
Register a Rust closure WorkerFn under fn_id, wrapping it so
it matches the WorkerFn signature (boxed, pinned future).
Trait Implementations§
Source§impl SpawnerFactory for RustFnInProcessSpawnerFactory
impl SpawnerFactory for RustFnInProcessSpawnerFactory
Source§fn build(
&self,
agent_def: &AgentDef,
_hint: Option<&Value>,
) -> Result<Arc<dyn SpawnerAdapter>, CompileError>
fn build( &self, agent_def: &AgentDef, _hint: Option<&Value>, ) -> Result<Arc<dyn SpawnerAdapter>, CompileError>
Build the concrete
SpawnerAdapter for one AgentDef. hint is
the matching entry (if any) from Blueprint.hints.per_agent.Source§impl SpawnerFactoryKind for RustFnInProcessSpawnerFactory
impl SpawnerFactoryKind for RustFnInProcessSpawnerFactory
Source§const KIND: AgentKind = AgentKind::RustFn
const KIND: AgentKind = AgentKind::RustFn
The
AgentKind this factory handles — used as the HashMap key
by SpawnerRegistry::register.Source§type Worker = RustFnWorker
type Worker = RustFnWorker
The concrete Worker type produced by this
AgentKind — this
binds the type chain all the way from AgentKind down to Worker.
Every factory declares it so the AgentKind → Worker mapping is
explicit across all four layers. It is the source of truth for
preserving the concrete type right up until SpawnerAdapter::spawn
erases it into Box<dyn Worker>.Auto Trait Implementations§
impl !RefUnwindSafe for RustFnInProcessSpawnerFactory
impl !UnwindSafe for RustFnInProcessSpawnerFactory
impl Freeze for RustFnInProcessSpawnerFactory
impl Send for RustFnInProcessSpawnerFactory
impl Sync for RustFnInProcessSpawnerFactory
impl Unpin for RustFnInProcessSpawnerFactory
impl UnsafeUnpin for RustFnInProcessSpawnerFactory
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more