Public declaration syntax from forge-rs/crates/forge-comm/src/message.rs Original source SHA-256: a42919cfd41b1182096aa4c9950d6190390224837d9bb2b7de0b5172d2eb3668 Function bodies and constant values are omitted. This is not the complete implementation. Source line 49 pub const NONCE_LEN: usize; Source line 93 #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] pub struct AgentMessage { /// Unique message identifier (UUID v4). pub id: String, /// Correlation ID linking related messages in a conversation. #[serde(skip_serializing_if = "Option::is_none")] pub correlation_id: Option, /// Message ID this is a direct reply to. #[serde(skip_serializing_if = "Option::is_none")] pub reply_to: Option, /// Sender's OAS DID. pub sender: String, /// Recipient's OAS DID. pub recipient: String, /// Protocol identifier (dot-separated, e.g., `"anvil.task.v1"`). pub protocol: String, /// Message type within the protocol. pub message_type: String, /// JSON payload, opaque to the transport layer. pub payload: serde_json::Value, /// Ed25519 signature of the message (hex-encoded). /// /// Computed over [`AgentMessage::signing_bytes`], which includes the /// replay-protection `nonce` and `timestamp_ms` fields. Verification /// uses the sender's public key resolved from their OAS DID document. #[serde(skip_serializing_if = "Option::is_none")] pub signature: Option, /// ISO 8601 creation timestamp (human-readable). /// /// For replay protection use [`timestamp_ms`](Self::timestamp_ms); this /// field is retained for logging and audit trails. pub timestamp: String, /// Unix-epoch milliseconds at send time. Covered by the signature. /// /// `None` only for envelopes deserialized from a pre-replay-protection /// wire format. Present on every message produced by [`AgentMessage::new`]. #[serde(skip_serializing_if = "Option::is_none")] pub timestamp_ms: Option, /// 16-byte random nonce, hex-encoded. Covered by the signature. /// /// `None` only for envelopes deserialized from a pre-replay-protection /// wire format. Present on every message produced by [`AgentMessage::new`]. #[serde(skip_serializing_if = "Option::is_none")] pub nonce: Option } Source line 167 pub fn new( sender: impl Into, recipient: impl Into, protocol: impl Into, message_type: impl Into, payload: serde_json::Value, ) -> Self; Source line 197 pub fn kind(&self) -> &str; Source line 203 pub fn is_signed(&self) -> bool; Source line 212 pub fn has_replay_fields(&self) -> bool; Source line 217 pub fn nonce_bytes(&self) -> Option<[u8; NONCE_LEN]>; Source line 223 pub fn with_correlation_id(mut self, id: String) -> Self; Source line 229 pub fn with_reply_to(mut self, id: String) -> Self; Source line 239 pub fn with_replay_fields(mut self, timestamp_ms: i64, nonce: [u8; NONCE_LEN]) -> Self; Source line 262 pub fn signing_bytes(&self) -> Vec; Source line 287 pub fn validate_replay( &self, validator: &forge_core::replay::ReplayValidator, ) -> Result<(), forge_core::replay::ReplayError>;