pub enum Part {
Text(TextPart),
File(FilePart),
Data(DataPart),
}Expand description
A unit of content within a Message.
The wire form is the proto’s oneof content:
the JSON object has exactly one of
text, file, or data as a top-level
field. The optional metadata field rides
alongside whichever content field is
present.
§Examples
use protocol_droid::domain::a2a::message::{Message, MessageRole, Part, TextPart};
let message = Message::new(MessageRole::User)
.with_part(Part::Text(TextPart {
text: "Hello, agent.".to_owned(),
metadata: std::collections::BTreeMap::new(),
}));
let json = serde_json::to_string(&message).unwrap();
assert!(json.contains(r#""role":"user""#));
assert!(json.contains(r#""text":"Hello, agent.""#));Variants§
Text(TextPart)
A UTF-8 string. Wire form:
{ "text": "..." }.
File(FilePart)
A file (named, MIME-typed, with either an
inline base64 payload or a URI). Wire
form: { "file": {...} }.
Data(DataPart)
A structured JSON value. Wire form:
{ "data": {...} }.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Part
impl<'de> Deserialize<'de> for Part
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
impl Eq for Part
impl StructuralPartialEq for Part
Auto Trait Implementations§
impl Freeze for Part
impl RefUnwindSafe for Part
impl Send for Part
impl Sync for Part
impl Unpin for Part
impl UnsafeUnpin for Part
impl UnwindSafe for Part
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