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: i64Unix 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: MessageFlagsImplementations§
Source§impl Message
impl Message
Sourcepub fn group_key(&self) -> Option<GroupKey<'_>>
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
impl Message
Sourcepub fn live(speaker: Speaker, body: ParsedText) -> Message
pub fn live(speaker: Speaker, body: ParsedText) -> Message
A live message with a single text body.
Sourcepub fn system(body: ParsedText) -> Message
pub fn system(body: ParsedText) -> Message
A client-generated notice with no speaker.
Sourcepub fn compact(&mut self)
pub fn compact(&mut self)
Give back the spare capacity building the message left behind. See
ParsedText::compact.
pub fn with_flags(self, f: MessageFlags) -> Message
pub fn with_timestamp(self, ts: i64) -> Message
Sourcepub fn to_plain_text(&self) -> String
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.