Public declaration syntax from forge-rs/crates/forge-comm/src/transport.rs Original source SHA-256: 308622255b99934d699e2a41452ca5ec329c82b11799e80d76b24e3dab3098bd Function bodies and constant values are omitted. This is not the complete implementation. Source line 59 #[async_trait::async_trait] pub trait MessageTransport: Send + Sync { /// Send a message to the recipient identified in the message envelope. /// /// The transport delivers the message to the recipient's receive queue. /// Delivery semantics (at-most-once, at-least-once, exactly-once) depend /// on the specific transport implementation. /// /// # Arguments /// /// * `message` - The agent message envelope to send. /// /// # Errors /// /// Returns [`CommError::TransportFailed`] if the underlying mechanism fails, /// [`CommError::ChannelClosed`] if the peer endpoint has been dropped, or /// [`CommError::MessageTooLarge`] if the message exceeds transport limits. async fn send(&self, message: AgentMessage) -> Result<(), CommError>; /// Receive the next available message. /// /// This method waits asynchronously until a message arrives or an error /// occurs. The specific blocking behavior depends on the transport /// implementation: channel transports suspend the current task, while /// network transports may perform I/O polling. /// /// # Errors /// /// Returns [`CommError::NotConnected`] if the transport is not active, /// [`CommError::ChannelClosed`] if the peer endpoint has been dropped, or /// [`CommError::TransportFailed`] for other transport-level failures. async fn receive(&self) -> Result; /// Receive the next available message and enforce replay protection. /// /// This is the preferred receive path for any caller that has already /// verified the sender's Ed25519 signature (or is about to, in a /// subsequent step). It delegates to [`receive`](Self::receive) to pull /// the next envelope off the wire, then calls /// [`AgentMessage::validate_replay`](crate::message::AgentMessage::validate_replay) /// with the provided `validator`. /// /// The replay validator enforces two invariants (see /// [`forge_core::replay::ReplayValidator`]): /// /// 1. The envelope's `timestamp_ms` must be within the validator's /// configured clock-skew window. /// 2. The envelope's `nonce` must not have been seen before, within the /// validity window. /// /// Legacy envelopes (no `nonce`/`timestamp_ms`) are rejected unless the /// validator has been configured with `accept_legacy = true` or the /// `FORGE_ACCEPT_LEGACY_MESSAGES=true` env flag is honored by the /// caller's [`forge_core::replay::ReplayConfig`]. /// /// # Errors /// /// - Any error returned by [`receive`](Self::receive). /// - [`CommError::ReplayDetected`] if replay protection rejects the /// message. async fn receive_validated( &self, validator: &ReplayValidator, ) -> Result ; }