pub struct TaskInputMiddleware { /* private fields */ }Expand description
SpawnerLayer that drops task-level execution context (project_root /
work_dir / task_metadata) into ctx just before spawn.
Each field is independent: any subset may be Some (see
Self::from_init_ctx for how they are extracted from init_ctx).
Absent fields insert no key at all — no empty-string / Value::Null
placeholder — so downstream .get(...) misses cleanly instead of
observing a hollow value.
Implementations§
Source§impl TaskInputMiddleware
impl TaskInputMiddleware
Sourcepub fn new(
project_root: Option<String>,
work_dir: Option<String>,
task_metadata: Option<Value>,
) -> Self
pub fn new( project_root: Option<String>, work_dir: Option<String>, task_metadata: Option<Value>, ) -> Self
Builds a layer from already-resolved field values. Prefer
Self::new_from_fields (or Self::from_init_ctx when the
source is a raw init_ctx body) when the “all three absent → no
layer” contract matters to the caller — this constructor always
returns a (possibly no-op) Self, never None.
Sourcepub fn new_from_fields(
project_root: Option<String>,
work_dir: Option<String>,
task_metadata: Option<Value>,
) -> Option<Self>
pub fn new_from_fields( project_root: Option<String>, work_dir: Option<String>, task_metadata: Option<Value>, ) -> Option<Self>
Issue #19 ST2 preferred constructor: builds from already-resolved
canonical Task-level field values (the wire boundary — e.g.
mlua-swarm-server’s run_flow_form — resolves sibling body
fields, falling back to the legacy init_ctx-nested shape only
there) rather than pulling them back out of init_ctx itself.
init_ctx stays a pure flow-ir eval seed with no promoted keys
folded back in.
Returns None when all three fields are absent — same no-op
contract as Self::from_init_ctx, so callers can use
Option::map/match uniformly regardless of which constructor
produced the layer.
Sourcepub fn from_init_ctx(init_ctx: &Value) -> Option<Self>
👎Deprecated: issue #19 ST2: prefer new_from_fields (or resolve the wire’s legacy init_ctx-nested shape at the wire boundary and pass the result through TaskLaunchInput.task_input instead)
pub fn from_init_ctx(init_ctx: &Value) -> Option<Self>
issue #19 ST2: prefer new_from_fields (or resolve the wire’s legacy init_ctx-nested shape at the wire boundary and pass the result through TaskLaunchInput.task_input instead)
Extracts project_root (string) / work_dir (string) /
task_metadata (object) from a top-level init_ctx object, each
independently optional.
Returns None when init_ctx is not a JSON object, or is an object
with none of the three keys present in the expected shape (a
present-but-wrong-typed value, e.g. "work_dir": 42, is treated the
same as absent — this is a best-effort task-level convenience
injection, not a request-body validator; malformed request bodies
are the request layer’s concern). Callers only layer the returned
middleware onto the spawner stack when this is Some, keeping the
no-op path identical to today’s behavior.
Deprecated (issue #19 ST2): TaskLaunchService::launch no longer
calls this — it now reads crate::service::task_launch::TaskLaunchInput::task_input
(built via Self::new_from_fields) instead of extracting from
init_ctx. Kept for callers still relying on the nested-in-init_ctx
shape being pulled directly out of an arbitrary Value (not
currently exercised inside this crate, but a public, documented
constructor — removing it outright would be a breaking API change
for downstream users of this middleware in isolation).
Trait Implementations§
Source§impl SpawnerLayer for TaskInputMiddleware
impl SpawnerLayer for TaskInputMiddleware
Source§fn wrap(&self, inner: Arc<dyn SpawnerAdapter>) -> Arc<dyn SpawnerAdapter> ⓘ
fn wrap(&self, inner: Arc<dyn SpawnerAdapter>) -> Arc<dyn SpawnerAdapter> ⓘ
inner in this layer’s behaviour, returning a new
SpawnerAdapter that delegates to inner (directly or via
wrap_join) while adding this layer’s cross-cutting effect.Auto Trait Implementations§
impl Freeze for TaskInputMiddleware
impl RefUnwindSafe for TaskInputMiddleware
impl Send for TaskInputMiddleware
impl Sync for TaskInputMiddleware
impl Unpin for TaskInputMiddleware
impl UnsafeUnpin for TaskInputMiddleware
impl UnwindSafe for TaskInputMiddleware
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
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>
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>
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