umsh_node/
transport.rs

1use umsh_core::PublicKey;
2use umsh_mac::SendOptions;
3
4use crate::ticket::SendProgressTicket;
5
6/// A context through which UMSH frames can be sent.
7///
8/// Both `LocalNode` and `BoundChannel` implement this trait, allowing
9/// generic code over the transport context.
10///
11/// **Important:** `Transport` is a *context* abstraction, not a *security*
12/// abstraction. `LocalNode::send()` produces a unicast frame (destination-
13/// encrypted, only the recipient can decrypt). `BoundChannel::send()`
14/// produces a blind unicast frame (channel-encrypted — any node with the
15/// channel key can decrypt). Generic code over `Transport` must not assume
16/// identical delivery or privacy properties.
17pub trait Transport {
18    type Error;
19
20    /// Send a payload to a specific destination.
21    ///
22    /// - On `LocalNode`: unicast (destination-encrypted)
23    /// - On `BoundChannel`: blind unicast (channel-encrypted)
24    async fn send(
25        &self,
26        to: &PublicKey,
27        payload: &[u8],
28        options: &SendOptions,
29    ) -> Result<SendProgressTicket, Self::Error>;
30
31    /// Send a payload to all reachable nodes in this transport's scope.
32    ///
33    /// - On `LocalNode`: broadcast (unauthenticated)
34    /// - On `BoundChannel`: multicast (channel-encrypted)
35    async fn send_all(
36        &self,
37        payload: &[u8],
38        options: &SendOptions,
39    ) -> Result<SendProgressTicket, Self::Error>;
40}