pub struct SerializableMessage {
pub role: MessageRole,
pub content: String,
pub timestamp: DateTime<Utc>,
}Expand description
A serializable message that can be converted to/from rig::completion::Message.
This struct provides a unified message format that can be stored, serialized, and optionally converted to other formats like rig’s Message type.
§Examples
use graph_flow::{SerializableMessage, MessageRole};
// Create different types of messages
let user_msg = SerializableMessage::user("Hello!".to_string());
let assistant_msg = SerializableMessage::assistant("Hi there!".to_string());
let system_msg = SerializableMessage::system("Session started".to_string());
// Access message properties
assert_eq!(user_msg.role, MessageRole::User);
assert_eq!(user_msg.content, "Hello!");Fields§
§role: MessageRoleThe role of the message sender
content: StringThe content of the message
timestamp: DateTime<Utc>When the message was created
Implementations§
Source§impl SerializableMessage
impl SerializableMessage
Sourcepub fn new(role: MessageRole, content: String) -> Self
pub fn new(role: MessageRole, content: String) -> Self
Create a new message with the specified role and content.
The timestamp is automatically set to the current UTC time.
Sourcepub fn user(content: String) -> Self
pub fn user(content: String) -> Self
Create a new user message.
§Examples
use graph_flow::SerializableMessage;
let msg = SerializableMessage::user("Hello, world!".to_string());Trait Implementations§
Source§impl Clone for SerializableMessage
impl Clone for SerializableMessage
Source§fn clone(&self) -> SerializableMessage
fn clone(&self) -> SerializableMessage
Returns a duplicate of the value. Read more
1.0.0 · 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 SerializableMessage
impl Debug for SerializableMessage
Source§impl<'de> Deserialize<'de> for SerializableMessage
impl<'de> Deserialize<'de> for SerializableMessage
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 SerializableMessage
impl RefUnwindSafe for SerializableMessage
impl Send for SerializableMessage
impl Sync for SerializableMessage
impl Unpin for SerializableMessage
impl UnwindSafe for SerializableMessage
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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