pub struct ChatMessage { /* private fields */ }Expand description
One application-owned message snapshot rendered by Chat.
IDs must be unique within a controlled snapshot. The message keeps all
progressive content and interaction metadata immutable; applications
replace the enclosing Arc<[ChatMessage]> as work advances.
Implementations§
Source§impl ChatMessage
impl ChatMessage
Sourcepub fn new(
id: impl Into<SharedString>,
role: ChatRole,
content: StreamedContent,
) -> Self
pub fn new( id: impl Into<SharedString>, role: ChatRole, content: StreamedContent, ) -> Self
Creates a message with stable application identity and progressive text.
Sourcepub fn actions(self, actions: MessageActions) -> Self
pub fn actions(self, actions: MessageActions) -> Self
Overrides the actions this message offers (default: MessageActions::for_role).
Sourcepub fn message_actions(&self) -> MessageActions
pub fn message_actions(&self) -> MessageActions
The actions this message offers.
Sourcepub fn with_appearance(self, appearance: ChatMessageAppearance) -> Self
pub fn with_appearance(self, appearance: ChatMessageAppearance) -> Self
Sets this message’s presentation (alignment and bubble treatment).
Sourcepub fn appearance(&self) -> &ChatMessageAppearance
pub fn appearance(&self) -> &ChatMessageAppearance
This message’s presentation.
Adds an optional visible author name.
Sourcepub fn citations(self, citations: impl IntoIterator<Item = CitationRef>) -> Self
pub fn citations(self, citations: impl IntoIterator<Item = CitationRef>) -> Self
Adds application-owned inline citation metadata.
Sourcepub fn sources(
self,
sources: impl IntoIterator<Item = impl Into<SharedString>>,
) -> Self
pub fn sources( self, sources: impl IntoIterator<Item = impl Into<SharedString>>, ) -> Self
Adds source labels shown after progressive content settles.
Sourcepub fn follow_ups(self, follow_ups: impl IntoIterator<Item = FollowUp>) -> Self
pub fn follow_ups(self, follow_ups: impl IntoIterator<Item = FollowUp>) -> Self
Adds stable follow-up suggestions.
Sourcepub fn attachments(
self,
attachments: impl IntoIterator<Item = Attachment>,
) -> Self
pub fn attachments( self, attachments: impl IntoIterator<Item = Attachment>, ) -> Self
Attaches files shown read-only above the content; activating one
reports ChatEvent::AttachmentActivated.
Sourcepub fn branch(self, position: BranchPosition) -> Self
pub fn branch(self, position: BranchPosition) -> Self
Marks this message as one of several versions; the header shows a
switcher that reports ChatEvent::BranchSelected.
Sourcepub fn retryable(self, retryable: bool) -> Self
pub fn retryable(self, retryable: bool) -> Self
Controls whether a failed message exposes a retry action.
Returns the optional visible author.
Sourcepub fn content(&self) -> &StreamedContent
pub fn content(&self) -> &StreamedContent
Returns the progressive content snapshot.
Sourcepub fn citation_refs(&self) -> &[CitationRef]
pub fn citation_refs(&self) -> &[CitationRef]
Returns inline citation metadata.
Sourcepub fn source_labels(&self) -> &[SharedString]
pub fn source_labels(&self) -> &[SharedString]
Returns source labels.
Sourcepub fn follow_up_suggestions(&self) -> &[FollowUp]
pub fn follow_up_suggestions(&self) -> &[FollowUp]
Returns follow-up suggestions.
Sourcepub fn attachment_refs(&self) -> &[Attachment]
pub fn attachment_refs(&self) -> &[Attachment]
Returns the attachments carried by this message.
Sourcepub fn branch_position(&self) -> Option<BranchPosition>
pub fn branch_position(&self) -> Option<BranchPosition>
Returns where this message sits among its versions, if branched.
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Returns whether a failed message may be retried.
Trait Implementations§
Source§impl Clone for ChatMessage
impl Clone for ChatMessage
Source§fn clone(&self) -> ChatMessage
fn clone(&self) -> ChatMessage
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ChatMessage
impl Debug for ChatMessage
impl Eq for ChatMessage
Source§impl PartialEq for ChatMessage
impl PartialEq 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Span], returning an
Instrumented wrapper.§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> ⓘ
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> ⓘ
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§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
Subscriber to this type, returning a
[WithDispatch] wrapper.