pub enum Message {
Simple {
performative: Performative,
recipient: Option<Recipients>,
content: SExpr,
params: Vec<SExpr>,
thread: Option<String>,
sender: Option<String>,
caused_by: Option<CausedBy>,
},
Meta {
dialect_def: SExpr,
},
Dialect {
dialect_name: String,
inner: Box<Message>,
},
Wrapped {
wrapper: WrapperType,
params: Vec<SExpr>,
content: Box<Message>,
},
}Expand description
A CBCL message (REQ-013).
Four variants matching the CBCL grammar:
Simple:(performative [recipient] content [:key val ...])Meta:(meta <operation>)Dialect:(lang <dialect-name> <inner-message>)Wrapped:(envelope|signed|with-limits <params...> <inner-message>)
Mirrors CBCL.Message in Message.lean:41–47 and
CBCL.MessageType in Message.lean:33–37.
Variants§
Simple
Simple message: (performative [recipient] content [:key val ...])
Meta
Meta message: (meta <dialect_def>)
Dialect
Dialect-scoped message: (lang <dialect_name> <inner>)
Wrapped
Wrapped message: (envelope|signed|with-limits <params...> <content>)
Implementations§
Source§impl Message
impl Message
Sourcepub fn parse_lax(sexpr: &SExpr) -> Result<Self, MessageParseError>
pub fn parse_lax(sexpr: &SExpr) -> Result<Self, MessageParseError>
Recognise a message as TryFrom<&SExpr> does, except that a custom
performative outside a (lang …) wrapper is accepted as a bare
Performative::Custom instead of being refused under the scoping rule.
For hosts that dispatch such a frame by its head name themselves and
accept only the names they know — the chat hub’s control plane
(adddialect, fetchdialect, addagent, …), which its lax parser
gates with a performative allow-list. Content messages go through
TryFrom, where the scoping rule stands: nothing in a bare custom head
says which dialect defines it.
Sourcepub fn message_type(&self) -> MessageType
pub fn message_type(&self) -> MessageType
Returns the message type classification.
Sourcepub fn performative(&self) -> Option<&Performative>
pub fn performative(&self) -> Option<&Performative>
Returns the performative if this is a Simple message.
Sourcepub fn recipient(&self) -> Option<&str>
pub fn recipient(&self) -> Option<&str>
Returns the recipient if this is a Simple message with exactly one.
Sourcepub fn canonical_recipient(&self) -> Result<&str, &'static str>
pub fn canonical_recipient(&self) -> Result<&str, &'static str>
Canonical signed-envelope audience, retaining the @ sigil.
Descends wrappers to the act. An outermost envelope routes a non-empty
recipient position through its single symbol :to (cbcl-bus SPEC-100
CON-009). Recipient-less, ambiguous and un-enveloped multicast frames
fail closed. Meta operations have no message recipient.
Sourcepub fn recipient_set(&self) -> BTreeSet<&str>
pub fn recipient_set(&self) -> BTreeSet<&str>
Returns all recipients of a Simple message as a normalized set (empty when the recipient position is absent) — SPEC-014 REQ-622.
Sourcepub fn caused_by(&self) -> Option<&CausedBy>
pub fn caused_by(&self) -> Option<&CausedBy>
Returns the caused-by reference if this is a Simple message with one.
Sourcepub fn dialect_def(&self) -> Option<&SExpr>
pub fn dialect_def(&self) -> Option<&SExpr>
Returns the dialect definition if this is a Meta message.
Sourcepub fn dialect_name(&self) -> Option<&str>
pub fn dialect_name(&self) -> Option<&str>
Returns the dialect name if this is a Dialect message.
Sourcepub fn inner_message(&self) -> Option<&Message>
pub fn inner_message(&self) -> Option<&Message>
Returns the inner message for Dialect or Wrapped messages.
Sourcepub fn innermost_simple(&self) -> Option<&Message>
pub fn innermost_simple(&self) -> Option<&Message>
Walk through Wrapped and Dialect envelopes to the innermost
Message::Simple. Returns None if no Simple is found (e.g. a Meta
message). Used by the parser pipeline and the agent to ensure
wrappers cannot be used to bypass causal/shape verification.
Sourcepub fn wrapper_type(&self) -> Option<WrapperType>
pub fn wrapper_type(&self) -> Option<WrapperType>
Returns the wrapper type if this is a Wrapped message.