pub struct TaskSpec { /* private fields */ }Expand description
The user’s durable intent - what should be executed.
Implementations§
Source§impl TaskSpec
impl TaskSpec
Sourcepub fn new(
id: TaskId,
payload: TaskPayload,
run_policy: RunPolicy,
constraints: TaskConstraints,
metadata: TaskMetadata,
) -> Result<Self, TaskSpecError>
pub fn new( id: TaskId, payload: TaskPayload, run_policy: RunPolicy, constraints: TaskConstraints, metadata: TaskMetadata, ) -> Result<Self, TaskSpecError>
Creates a task specification with validated constraints.
parent_task_id defaults to None. Use with_parent
to attach a parent before submission.
Sourcepub fn with_parent(self, parent_task_id: TaskId) -> Self
pub fn with_parent(self, parent_task_id: TaskId) -> Self
Attaches a parent task identifier, returning the modified spec.
Used by the workflow extension to declare parent-child relationships. The parent must exist in the projection when the child is submitted.
Uses debug_assert (not Result) because this is only called from
internal workflow submission paths where the parent ID has already been
validated against the projection. A nil parent indicates a logic error
in the submission pipeline, not invalid user input.
Sourcepub fn validate(&self) -> Result<(), TaskSpecError>
pub fn validate(&self) -> Result<(), TaskSpecError>
Validates this task specification against invariant-sensitive checks.
Sourcepub fn content_type(&self) -> Option<&str>
pub fn content_type(&self) -> Option<&str>
Returns the optional payload content-type hint.
Sourcepub fn task_payload(&self) -> &TaskPayload
pub fn task_payload(&self) -> &TaskPayload
Returns a reference to the full task payload (bytes + content-type).
Sourcepub fn run_policy(&self) -> &RunPolicy
pub fn run_policy(&self) -> &RunPolicy
Returns the run policy snapshot for this task.
Sourcepub fn constraints(&self) -> &TaskConstraints
pub fn constraints(&self) -> &TaskConstraints
Returns the constraints snapshot for this task.
Sourcepub fn metadata(&self) -> &TaskMetadata
pub fn metadata(&self) -> &TaskMetadata
Returns task metadata.
Sourcepub fn parent_task_id(&self) -> Option<TaskId>
pub fn parent_task_id(&self) -> Option<TaskId>
Returns the optional parent task identifier.
Sourcepub fn with_tenant(self, tenant_id: TenantId) -> Self
pub fn with_tenant(self, tenant_id: TenantId) -> Self
Attaches a tenant identifier, returning the modified spec.
Sourcepub fn set_constraints(
&mut self,
constraints: TaskConstraints,
) -> Result<(), TaskSpecError>
pub fn set_constraints( &mut self, constraints: TaskConstraints, ) -> Result<(), TaskSpecError>
Replaces task constraints after validating invariants.
Sourcepub fn set_metadata(&mut self, metadata: TaskMetadata)
pub fn set_metadata(&mut self, metadata: TaskMetadata)
Replaces task metadata.
Sourcepub fn set_payload(&mut self, payload: TaskPayload)
pub fn set_payload(&mut self, payload: TaskPayload)
Replaces payload bytes and optional content-type hint.
Sourcepub fn set_run_policy(
&mut self,
run_policy: RunPolicy,
) -> Result<(), TaskSpecError>
pub fn set_run_policy( &mut self, run_policy: RunPolicy, ) -> Result<(), TaskSpecError>
Replaces run policy after validating policy-shape invariants.