#[non_exhaustive]pub struct MessageChange {
pub index: usize,
pub id: MessageId,
pub kind: MessageChangeKind,
}Expand description
Which message changed, and how.
#[non_exhaustive]: read the fields, match with .., and build one, to
compare with what Applier::apply returned, with MessageChange::new.
use ag_ui::client::apply::{Applier, Changed, MessageChange, MessageChangeKind};
use ag_ui::{Event, TextMessageRole};
let mut applier = Applier::new();
let started = applier.apply(&Event::text_message_start("m-1", TextMessageRole::Assistant))?;
assert_eq!(
started,
Changed::Message(MessageChange::new(0, "m-1", MessageChangeKind::Started))
);A struct literal does not compile outside this crate:
ⓘ
use ag_ui::client::apply::{MessageChange, MessageChangeKind};
let change = MessageChange { index: 0, id: "m-1".into(), kind: MessageChangeKind::Ended };Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.index: usizeIndex into Applier::messages.
id: MessageIdThe message’s id.
kind: MessageChangeKindWhat happened to it.
Implementations§
Source§impl MessageChange
impl MessageChange
Sourcepub fn new(
index: usize,
id: impl Into<MessageId>,
kind: MessageChangeKind,
) -> Self
pub fn new( index: usize, id: impl Into<MessageId>, kind: MessageChangeKind, ) -> Self
A change of kind to the message id, at index of
Applier::messages.
Trait Implementations§
Source§impl Clone for MessageChange
impl Clone for MessageChange
Source§impl Debug for MessageChange
impl Debug for MessageChange
Source§impl PartialEq for MessageChange
impl PartialEq for MessageChange
impl StructuralPartialEq for MessageChange
Auto Trait Implementations§
impl Freeze for MessageChange
impl RefUnwindSafe for MessageChange
impl Send for MessageChange
impl Sync for MessageChange
impl Unpin for MessageChange
impl UnsafeUnpin for MessageChange
impl UnwindSafe for MessageChange
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