pub struct ChatMessage(/* private fields */);Expand description
A typed chat message accepted by the provider request contract.
Use the role-specific constructors instead of constructing provider payloads directly:
use edge_completions::ChatMessage;
let message = ChatMessage::user("Explain trait boundaries.");
assert_eq!(message, ChatMessage::user("Explain trait boundaries."));Implementations§
Source§impl ChatMessage
impl ChatMessage
Sourcepub fn assistant_tool_calls(tool_calls: Vec<ToolCall>) -> Self
pub fn assistant_tool_calls(tool_calls: Vec<ToolCall>) -> Self
Replays provider-proposed tool calls in a follow-up request.
Sourcepub fn tool_result<T: ToolDefinition>(
call: &ToolCall,
result: &T::Output,
) -> Result<Self, ToolError>
pub fn tool_result<T: ToolDefinition>( call: &ToolCall, result: &T::Output, ) -> Result<Self, ToolError>
Encodes a typed tool result after confirming that the call name matches T.
Prefer ValidatedToolCall::result after calling
ToolCall::validate. That path carries the successful name and
argument validation in the type system.
§Errors
Returns ToolError::UnexpectedName when the proposed function name
does not match T::NAME, or ToolError::ResultEncoding when the typed
output cannot be serialized.
Trait Implementations§
Source§impl Clone for ChatMessage
impl Clone for ChatMessage
Source§fn clone(&self) -> ChatMessage
fn clone(&self) -> ChatMessage
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 ChatMessage
impl Debug for ChatMessage
Source§impl<'de> Deserialize<'de> for ChatMessage
impl<'de> Deserialize<'de> for ChatMessage
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 PartialEq for ChatMessage
impl PartialEq for ChatMessage
Source§impl Serialize for ChatMessage
impl Serialize for ChatMessage
impl StructuralPartialEq for ChatMessage
Auto Trait Implementations§
impl Freeze for ChatMessage
impl RefUnwindSafe for ChatMessage
impl Send for ChatMessage
impl Sync for ChatMessage
impl Unpin for ChatMessage
impl UnsafeUnpin for ChatMessage
impl UnwindSafe for ChatMessage
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