pub struct Message {
pub id: Uuid,
pub from_peer: String,
pub to_peer: String,
pub topic: String,
pub payload: Value,
pub sent_at: DateTime<Utc>,
pub read_at: Option<DateTime<Utc>>,
}Expand description
Represents a mail message stored in the mailbox.
§Definition
Message is a data structure that models a single mail exchange between two peers.
It contains a unique identifier, sender and recipient identifiers, a topic string, a JSON payload,
and timestamps for when the message was sent and optionally when it was read.
§Implementation Details
idis a Uuid generated by the caller to guarantee global uniqueness.payloadusesserde_json::Valueso arbitrary JSON can be attached to the message.sent_atandread_atare stored aschrono::DateTime<Utc>to provide timezone‑agnostic timestamps.
§Rationale
This struct provides a lightweight, serialisable representation of a message that can be persisted
in the SQLite‑backed mailbox (see Mailbox). Keeping the payload as JSON allows different subsystems
of the CHORUS platform to embed domain‑specific data without requiring a rigid schema.
Fields§
§id: UuidGlobally unique identifier for the message.
from_peer: StringIdentifier of the sending peer.
to_peer: StringIdentifier of the receiving peer.
topic: StringTopic or channel of the message; used for routing/filters.
payload: ValueArbitrary JSON payload containing the message body.
sent_at: DateTime<Utc>Timestamp (UTC) when the message was sent.
read_at: Option<DateTime<Utc>>Optional timestamp (UTC) when the recipient read the message.