pub struct UIMessage {
pub id: String,
pub role: UIRole,
pub metadata: Option<Value>,
pub parts: Vec<UIMessagePart>,
}Expand description
A UI message with rich parts.
This is the source of truth for application state, representing the complete message including metadata, data parts, and all contextual information.
Fields§
§id: StringUnique identifier for this message.
role: UIRoleRole of the message sender.
metadata: Option<Value>Optional metadata.
parts: Vec<UIMessagePart>Message parts.
Implementations§
Source§impl UIMessage
impl UIMessage
Sourcepub fn with_metadata(self, metadata: Value) -> Self
pub fn with_metadata(self, metadata: Value) -> Self
Add metadata.
Sourcepub fn with_part(self, part: UIMessagePart) -> Self
pub fn with_part(self, part: UIMessagePart) -> Self
Add a part.
Sourcepub fn with_parts(self, parts: impl IntoIterator<Item = UIMessagePart>) -> Self
pub fn with_parts(self, parts: impl IntoIterator<Item = UIMessagePart>) -> Self
Add multiple parts.
Sourcepub fn text_content(&self) -> String
pub fn text_content(&self) -> String
Get all text content concatenated.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for UIMessage
impl<'de> Deserialize<'de> for UIMessage
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 StructuralPartialEq for UIMessage
Auto Trait Implementations§
impl Freeze for UIMessage
impl RefUnwindSafe for UIMessage
impl Send for UIMessage
impl Sync for UIMessage
impl Unpin for UIMessage
impl UnwindSafe for UIMessage
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