pub struct Message {
pub role: Role,
pub content: String,
pub timestamp: DateTime<Utc>,
/* private fields */
}Fields§
§role: Role§content: String§timestamp: DateTime<Utc>Implementations§
Source§impl Message
impl Message
pub fn code_blocks(&self) -> Vec<&CodeBlock>
pub fn non_code_content(&self) -> &str
pub fn new(role: Role, content: &str, timestamp: DateTime<Utc>) -> Self
pub fn new_user(text: &str) -> Self
pub fn new_asst(text: &str) -> Self
pub fn update(&mut self, text: &str)
pub fn new_from_db(role: Role, content: String, timestamp_epoch: f64) -> Self
pub fn timestamp_epoch(&self) -> f64
pub fn timestamp_millis(&self) -> i64
pub fn is_user(&self) -> bool
pub fn is_assistant(&self) -> bool
pub fn is_system(&self) -> bool
Sourcepub fn formatted_content<'a>(
&'a self,
index: &mut usize,
line_width: u16,
) -> Text<'a>
pub fn formatted_content<'a>( &'a self, index: &mut usize, line_width: u16, ) -> Text<'a>
Get the text for this message as it will be displayed, with highlights and annotations
index is the value to start numbering the block annotations from
Sourcepub fn update_blocks(&mut self)
pub fn update_blocks(&mut self)
update code_blocks and non_code_content to align with the message text
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Message
impl<'de> Deserialize<'de> for Message
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 Message
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl UnwindSafe for Message
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