Skip to main content

TaskInputMiddleware

Struct TaskInputMiddleware 

Source
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

Source

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.

Source

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.

Source

pub 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)

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

Source§

fn wrap(&self, inner: Arc<dyn SpawnerAdapter>) -> Arc<dyn SpawnerAdapter>

Wraps 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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> MaybeSend for T

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more