pub struct Task {
pub id: String,
pub context_id: Option<String>,
pub state: TaskState,
pub messages: Vec<Message>,
pub artifacts: Vec<Artifact>,
pub metadata: Option<Value>,
pub created_at: Option<DateTime<Utc>>,
pub updated_at: Option<DateTime<Utc>>,
}Expand description
A Task — the fundamental unit of work in A2A.
Fields§
§id: StringUnique identifier for this task.
context_id: Option<String>Optional context ID grouping related tasks for session coherence.
state: TaskStateCurrent state of the task.
messages: Vec<Message>Messages exchanged during the task (multi-turn conversation).
artifacts: Vec<Artifact>Artifacts produced by the task.
metadata: Option<Value>Optional metadata attached to the task.
created_at: Option<DateTime<Utc>>When the task was created.
updated_at: Option<DateTime<Utc>>When the task was last updated.
Implementations§
Source§impl Task
impl Task
Sourcepub fn with_context(context_id: impl Into<String>) -> Self
pub fn with_context(context_id: impl Into<String>) -> Self
Create a new task within a context (session).
Sourcepub fn is_terminal(&self) -> bool
pub fn is_terminal(&self) -> bool
Check if the task is in a terminal state.
Sourcepub fn is_interrupted(&self) -> bool
pub fn is_interrupted(&self) -> bool
Check if the task is in an interrupted state (needs input or auth).
Sourcepub fn transition(
&mut self,
new_state: TaskState,
) -> Result<(), InvalidTransition>
pub fn transition( &mut self, new_state: TaskState, ) -> Result<(), InvalidTransition>
Transition the task to a new state.
Sourcepub fn add_message(&mut self, message: Message)
pub fn add_message(&mut self, message: Message)
Add a message to the task.
Sourcepub fn add_artifact(&mut self, artifact: Artifact)
pub fn add_artifact(&mut self, artifact: Artifact)
Add an artifact to the task.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Task
impl<'de> Deserialize<'de> for Task
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl JsonSchema for Task
impl JsonSchema for Task
Source§fn schema_name() -> String
fn schema_name() -> String
The name of the generated JSON Schema. Read more
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
Whether JSON Schemas generated for this type should be re-used where possible using the
$ref keyword. Read moreAuto 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> 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
Mutably borrows from an owned value. Read more