pub struct Message {
pub role: String,
pub content: Option<Content>,
pub tool_calls: Vec<Value>,
pub extra: Map<String, Value>,
}Expand description
A single chat message. role is typed; content is string-or-parts; all other keys
(name, tool_call_id, …) flow through extra.
Fields§
§role: String"system" | "user" | "assistant" | "tool" | … — open by design.
content: Option<Content>Message body: a plain string, or a list of multimodal parts. None omits the key
entirely (faithful to messages that carry only tool_calls).
tool_calls: Vec<Value>Assistant tool-call payloads, raw JSON (shape varies by model:
function.arguments is sometimes a dict, sometimes a JSON string).
extra: Map<String, Value>Any other per-message keys (name, tool_call_id, model-specific fields).
Implementations§
Source§impl Message
impl Message
Sourcepub fn new(role: impl Into<String>, content: impl Into<String>) -> Self
pub fn new(role: impl Into<String>, content: impl Into<String>) -> Self
Convenience constructor for the common {role, content: <text>} message.
Sourcepub fn system(content: impl Into<String>) -> Self
pub fn system(content: impl Into<String>) -> Self
A system message with text content. Shorthand for Message::new("system", text).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Message
impl<'de> Deserialize<'de> for Message
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
Auto Trait Implementations§
impl Freeze for Message
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl UnsafeUnpin for Message
impl UnwindSafe for Message
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