Skip to main content

Task

Struct Task 

Source
#[non_exhaustive]
pub struct Task { /* private fields */ }
Expand description

Ergonomic wrapper over proto Task.

Implementations§

Source§

impl Task

Source

pub fn new(id: impl Into<String>, status: TaskStatus) -> Self

Source

pub fn with_context_id(self, context_id: impl Into<String>) -> Self

Source

pub fn id(&self) -> &str

Source

pub fn context_id(&self) -> &str

Source

pub fn status(&self) -> Option<TaskStatus>

Source

pub fn history(&self) -> &[Message]

Source

pub fn artifacts(&self) -> &[Artifact]

Source

pub fn append_message(&mut self, message: Message)

Source

pub fn append_artifact(&mut self, artifact: Artifact)

Source

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 same artifactId is already on the task, extend its parts with 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.

Source

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.

Source

pub fn complete(&mut self)

Mark the task as completed.

Source

pub fn fail(&mut self, message: impl Into<String>)

Mark the task as failed with an optional message.

Source

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.

Source

pub fn as_proto(&self) -> &Task

Source

pub fn as_proto_mut(&mut self) -> &mut Task

Source

pub fn into_proto(self) -> Task

Trait Implementations§

Source§

impl Clone for Task

Source§

fn clone(&self) -> Task

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Task

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Task

Source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

impl From<Task> for Task

Source§

fn from(task: Task) -> Self

Converts to this type from the input type.
Source§

impl Serialize for Task

Source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
Source§

impl TryFrom<Task> for Task

Source§

type Error = A2aTypeError

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

fn try_from(inner: Task) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl Freeze for Task

§

impl RefUnwindSafe for Task

§

impl Send for Task

§

impl Sync for Task

§

impl Unpin for Task

§

impl UnsafeUnpin for Task

§

impl UnwindSafe for Task

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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,