Skip to main content

EncryptedChannel

Trait EncryptedChannel 

Source
pub trait EncryptedChannel:
    Send
    + Sync
    + 'static {
    // Required methods
    fn send_encrypted<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        plaintext: &'life1 [u8],
    ) -> Pin<Box<dyn Future<Output = Result<(), MeshError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn recv_encrypted<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, MeshError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn remote_static_key(&self) -> Option<&[u8]>;
    fn close<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<(), MeshError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided method
    fn handshake_hash(&self) -> Option<&[u8]> { ... }
}
Expand description

Encrypted channel wrapping a raw mesh stream.

After a Noise handshake completes, all traffic flows through this interface. Each send_encrypted / recv_encrypted call handles framing, encryption, and authentication transparently.

§Cancel-safety (ADR-010 / WEFT-18)

recv_encrypted is raced in tokio::select! (mesh peer loop). It must be cancel-safe: implementors delegate to MeshStream::recv, which itself must retain partial frame progress across cancellation.

Required Methods§

Source

fn send_encrypted<'life0, 'life1, 'async_trait>( &'life0 mut self, plaintext: &'life1 [u8], ) -> Pin<Box<dyn Future<Output = Result<(), MeshError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Send encrypted data (plaintext in, ciphertext on the wire).

Source

fn recv_encrypted<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, MeshError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Receive and decrypt data (ciphertext from wire, plaintext out).

Cancel-safe: may be dropped while pending inside tokio::select!.

Source

fn remote_static_key(&self) -> Option<&[u8]>

Get the remote peer’s static public key (after handshake).

Source

fn close<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<(), MeshError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Close the encrypted channel gracefully.

Provided Methods§

Source

fn handshake_hash(&self) -> Option<&[u8]>

The Noise handshake hash of this session, when the channel has one. Both sides of a session compute the same value; admission signs it to bind a node identity to this exact session (P3-K1). None for channels without a handshake (plaintext passthrough).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§