#[non_exhaustive]pub struct Task { /* private fields */ }Expand description
Ergonomic wrapper over proto Task.
Implementations§
Source§impl Task
impl Task
pub fn new(id: impl Into<String>, status: TaskStatus) -> Self
pub fn with_context_id(self, context_id: impl Into<String>) -> Self
pub fn id(&self) -> &str
pub fn context_id(&self) -> &str
pub fn status(&self) -> Option<TaskStatus>
pub fn history(&self) -> &[Message]
pub fn artifacts(&self) -> &[Artifact]
pub fn append_message(&mut self, message: Message)
pub fn append_artifact(&mut self, artifact: Artifact)
Sourcepub fn merge_artifact(
&mut self,
artifact: Artifact,
append: bool,
_last_chunk: bool,
)
pub fn merge_artifact( &mut self, artifact: Artifact, append: bool, _last_chunk: bool, )
Merge an artifact using A2A streaming append semantics.
append = true: if an artifact with the sameartifactIdis already on the task, extend itspartswith the incoming parts (same as a streaming-chunk continuation). Otherwise, append as a new entry.append = false: append unconditionally (new entry or caller tolerates duplicate ids).
The last_chunk flag is transport-only metadata
— it is not persisted on the task. It is accepted here so callers
can keep the signature symmetric with the streaming wire event
payload and not drop the parameter separately.
This mirrors the server storage append-artifact semantics so that in-memory task mutations and the storage layer converge on the same view. The storage trait lives in the server crate; this helper is the dependency-free equivalent for wrapper callers.
Sourcepub fn set_status(&mut self, status: TaskStatus)
pub fn set_status(&mut self, status: TaskStatus)
Set the task’s status. This is the low-level escape hatch —
prefer complete(), fail(), etc. for common transitions.
Sourcepub fn fail(&mut self, message: impl Into<String>)
pub fn fail(&mut self, message: impl Into<String>)
Mark the task as failed with an optional message.
Sourcepub fn push_text_artifact(
&mut self,
artifact_id: impl Into<String>,
name: impl Into<String>,
text: impl Into<String>,
)
pub fn push_text_artifact( &mut self, artifact_id: impl Into<String>, name: impl Into<String>, text: impl Into<String>, )
Add a text artifact to the task.