#[non_exhaustive]pub enum SendMessageResponse {
Task(Task),
Message(Message),
}Expand description
Represents the response for the SendMessage method.
In JSON this is the proto’s oneof payload, externally tagged:
{"task": {...}} or {"message": {...}}.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Implementations§
Source§impl SendMessageResponse
impl SendMessageResponse
Sourcepub const fn as_task(&self) -> Option<&Task>
pub const fn as_task(&self) -> Option<&Task>
The task, if the agent answered with one.
use a2a_protocol_types::responses::SendMessageResponse;
use a2a_protocol_types::task::{Task, TaskState, TaskStatus};
let answer = SendMessageResponse::Task(Task::new("t1", "c1", TaskStatus::new(TaskState::Completed)));
assert_eq!(answer.as_task().map(|t| t.id.as_ref()), Some("t1"));
assert!(answer.as_message().is_none());Sourcepub fn into_task(self) -> Option<Task>
pub fn into_task(self) -> Option<Task>
The task, consuming the answer, if the agent answered with one.
Sourcepub const fn as_message(&self) -> Option<&Message>
pub const fn as_message(&self) -> Option<&Message>
The message, if the agent answered with one rather than a task.
Sourcepub fn into_message(self) -> Option<Message>
pub fn into_message(self) -> Option<Message>
The message, consuming the answer, if the agent answered with one.
Sourcepub fn text(&self) -> Option<&str>
pub fn text(&self) -> Option<&str>
The first text the answer carries: a message’s first text part, or the
first artifact text of a task (Task::text). None when there is
none, as for a task that has not produced an artifact yet.
use a2a_protocol_types::message::Message;
use a2a_protocol_types::responses::SendMessageResponse;
let answer = SendMessageResponse::Message(Message::user_text("m1", "hello"));
assert_eq!(answer.text(), Some("hello"));Trait Implementations§
Source§impl Clone for SendMessageResponse
impl Clone for SendMessageResponse
Source§fn clone(&self) -> SendMessageResponse
fn clone(&self) -> SendMessageResponse
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SendMessageResponse
impl Debug for SendMessageResponse
Source§impl<'de> Deserialize<'de> for SendMessageResponse
impl<'de> Deserialize<'de> for SendMessageResponse
Source§fn deserialize<D>(
deserializer: D,
) -> Result<SendMessageResponse, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<SendMessageResponse, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for SendMessageResponse
impl Serialize for SendMessageResponse
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Source§impl TryFrom<SendMessageResponse> for SendMessageResponse
impl TryFrom<SendMessageResponse> for SendMessageResponse
Source§type Error = ConvertError
type Error = ConvertError
The type returned in the event of a conversion error.
Source§fn try_from(
value: SendMessageResponse,
) -> Result<SendMessageResponse, <SendMessageResponse as TryFrom<SendMessageResponse>>::Error>
fn try_from( value: SendMessageResponse, ) -> Result<SendMessageResponse, <SendMessageResponse as TryFrom<SendMessageResponse>>::Error>
Performs the conversion.
Source§impl TryFrom<SendMessageResponse> for SendMessageResponse
impl TryFrom<SendMessageResponse> for SendMessageResponse
Source§type Error = ConvertError
type Error = ConvertError
The type returned in the event of a conversion error.
Source§fn try_from(
value: SendMessageResponse,
) -> Result<SendMessageResponse, <SendMessageResponse as TryFrom<SendMessageResponse>>::Error>
fn try_from( value: SendMessageResponse, ) -> Result<SendMessageResponse, <SendMessageResponse as TryFrom<SendMessageResponse>>::Error>
Performs the conversion.
Auto Trait Implementations§
impl Forget for SendMessageResponse
impl Freeze for SendMessageResponse
impl Move for SendMessageResponse
impl RefUnwindSafe for SendMessageResponse
impl Send for SendMessageResponse
impl Sync for SendMessageResponse
impl Unpin for SendMessageResponse
impl UnsafeUnpin for SendMessageResponse
impl UnwindSafe for SendMessageResponse
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Applies the layer to a service and wraps it in [
Layered].