#[non_exhaustive]pub enum Message {
Human(HumanMessage),
Ai(AiMessage),
System(SystemMessage),
Tool(ToolMessage),
}Expand description
Top-level message enum — all message types the system handles.
§REVIEW(002): #[non_exhaustive] per library-design.md
This enum will grow (e.g. FunctionMessage, ToolResultMessage, RemoveMessage).
Without non_exhaustive, adding a variant is a breaking change for downstream
match arms. With it, users must have a _ => arm, enabling safe evolution.
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 Message
impl Message
pub fn human(content: impl Into<String>) -> Self
pub fn system(content: impl Into<String>) -> Self
pub fn ai(content: impl Into<String>) -> Self
pub fn tool(content: impl Into<String>, tool_call_id: impl Into<String>) -> Self
Sourcepub fn tool_with_metadata(
content: impl Into<String>,
tool_call_id: impl Into<String>,
metadata: Option<HashMap<String, Value>>,
duration_ms: Option<u64>,
) -> Self
pub fn tool_with_metadata( content: impl Into<String>, tool_call_id: impl Into<String>, metadata: Option<HashMap<String, Value>>, duration_ms: Option<u64>, ) -> Self
Create a tool message with metadata and duration.
pub fn id(&self) -> Option<&str>
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