Skip to main content

Message

Struct Message 

Source
pub struct Message {
    pub kind: MessageKind,
    pub timestamp: i64,
    pub speaker: Option<Speaker>,
    pub gutter: Option<ParsedText>,
    pub blocks: Blocks,
    pub flags: MessageFlags,
}
Expand description

A row.

Fields§

§kind: MessageKind§timestamp: i64

Unix seconds. The C API turns a stamp of 0 into “now”.

§speaker: Option<Speaker>§gutter: Option<ParsedText>

The nick column as the application styled it — brackets in one color, the name in another, a status tag — overriding the bare Self::speaker nick, which only sizes the column when this is absent.

§blocks: Blocks§flags: MessageFlags

Implementations§

Source§

impl Message

Source

pub fn group_key(&self) -> Option<GroupKey<'_>>

The key two messages must share to be grouped, or None for a message that never groups (system rows, dividers, /me).

Both halves matter, and each catches a case the other misses:

  • The key separates two people who happen to share a nick.
  • The rendered nick separates one person before and after a rename. The key survives a rename, so keying on it alone would group the messages and the new name would simply never appear — which is worse than repeating it, since the change is exactly what the reader needs to see.

The nick compared is the gutter text as drawn, not Speaker.nick, because what a reader notices is the label on screen changing.

Source§

impl Message

Source

pub fn live(speaker: Speaker, body: ParsedText) -> Message

A live message with a single text body.

Source

pub fn system(body: ParsedText) -> Message

A client-generated notice with no speaker.

Source

pub fn compact(&mut self)

Give back the spare capacity building the message left behind. See ParsedText::compact.

Source

pub fn with_flags(self, f: MessageFlags) -> Message

Source

pub fn with_timestamp(self, ts: i64) -> Message

Source

pub fn to_plain_text(&self) -> String

The plain text of the whole message, blocks joined by newlines. Used for clipboard extraction and for the search index; image blocks contribute their alt text, which is the behaviour xtext approximated by storing the placeholder as ent->str.

Trait Implementations§

Source§

impl Clone for Message

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Message

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Message

Source§

impl PartialEq for Message

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Message

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.