pub enum Message {
Join {
id: String,
room: String,
user: String,
ts: DateTime<Utc>,
seq: Option<u64>,
},
Leave {
id: String,
room: String,
user: String,
ts: DateTime<Utc>,
seq: Option<u64>,
},
Message {
id: String,
room: String,
user: String,
ts: DateTime<Utc>,
seq: Option<u64>,
content: String,
},
Reply {
id: String,
room: String,
user: String,
ts: DateTime<Utc>,
seq: Option<u64>,
reply_to: String,
content: String,
},
Command {
id: String,
room: String,
user: String,
ts: DateTime<Utc>,
seq: Option<u64>,
cmd: String,
params: Vec<String>,
},
System {
id: String,
room: String,
user: String,
ts: DateTime<Utc>,
seq: Option<u64>,
content: String,
},
DirectMessage {
id: String,
room: String,
user: String,
ts: DateTime<Utc>,
seq: Option<u64>,
to: String,
content: String,
},
}Expand description
Wire format for all messages stored in the chat file and sent over the socket.
Uses #[serde(tag = "type")] internally-tagged enum without #[serde(flatten)]
to avoid the serde flatten + internally-tagged footgun that breaks deserialization.
Every variant carries its own id/room/user/ts fields.
Variants§
Join
Leave
Message
Reply
Fields
Command
Fields
System
DirectMessage
A private direct message. Delivered only to sender, recipient, and the broker host. Always written to the chat history file.
Implementations§
Source§impl Message
impl Message
pub fn id(&self) -> &str
pub fn room(&self) -> &str
pub fn user(&self) -> &str
pub fn ts(&self) -> &DateTime<Utc>
Sourcepub fn seq(&self) -> Option<u64>
pub fn seq(&self) -> Option<u64>
Returns the sequence number assigned by the broker, or None for
messages loaded from history files that predate this feature.
Sourcepub fn content(&self) -> Option<&str>
pub fn content(&self) -> Option<&str>
Returns the text content of this message, or None for variants without content
(Join, Leave, Command).
Sourcepub fn mentions(&self) -> Vec<String>
pub fn mentions(&self) -> Vec<String>
Extract @mentions from this message’s content.
Returns an empty vec for variants without content (Join, Leave, Command) or content with no @mentions.
Sourcepub fn is_visible_to(&self, viewer: &str, host: Option<&str>) -> bool
pub fn is_visible_to(&self, viewer: &str, host: Option<&str>) -> bool
Returns true if viewer is allowed to see this message.
All non-DM variants are visible to everyone. A Message::DirectMessage
is visible only to the sender (user), the recipient (to), and the
room host (when host == Some(viewer)).