Module link_transport

Module link_transport 

Source
Expand description

This module provides the LinkTransport and LinkConn traits that abstract the transport layer for overlay networks like saorsa-core. This enables:

  • Version decoupling: Overlays can compile against a stable trait interface while ant-quic evolves underneath
  • Testing: Mock transports for unit testing overlay logic
  • Alternative transports: Future support for WebRTC, TCP fallback, etc.

§Architecture

┌─────────────────────────────────────────────────────────────────┐
│                      saorsa-core (overlay)                       │
│  DHT routing │ Record storage │ Greedy routing │ Naming         │
└─────────────────────────────────────────────────────────────────┘
                             │
                             ▼
┌─────────────────────────────────────────────────────────────────┐
│                    LinkTransport trait                          │
│  local_peer() │ peer_table() │ dial() │ accept() │ subscribe()  │
└─────────────────────────────────────────────────────────────────┘
                             │
                             ▼
┌─────────────────────────────────────────────────────────────────┐
│                  ant-quic P2pEndpoint                            │
│  QUIC transport │ NAT traversal │ PQC │ Connection management   │
└─────────────────────────────────────────────────────────────────┘

§Example

use ant_quic::link_transport::{LinkTransport, LinkConn, ProtocolId};

// Define your overlay's protocol
const DHT_PROTOCOL: ProtocolId = ProtocolId::from_static(b"saorsa-dht/1.0.0");

async fn run_overlay<T: LinkTransport>(transport: T) -> anyhow::Result<()> {
    // Accept incoming connections for our protocol
    let mut incoming = transport.accept(DHT_PROTOCOL);
     
    // Dial a peer
    let peer_id = /* ... */;
    let conn = transport.dial(peer_id, DHT_PROTOCOL).await?;
     
    // Open a bidirectional stream
    let (send, recv) = conn.open_bi().await?;
     
    Ok(())
}

Structs§

Capabilities
Capabilities and quality metrics for a connected peer.
ConnectionStats
Statistics for a connection.
ProtocolId
Protocol identifier for multiplexing multiple overlays on a single transport.

Enums§

DisconnectReason
Reason for peer disconnection.
LinkError
Errors that can occur during link transport operations.
LinkEvent
Events emitted by the link transport layer.
NatHint
NAT type classification hint for connection strategy selection.

Traits§

LinkConn
A connection to a remote peer.
LinkRecvStream
A receive stream for reading data from a peer.
LinkSendStream
A send stream for writing data to a peer.
LinkTransport
The primary transport abstraction for overlay networks.

Type Aliases§

BoxFuture
A boxed future for async operations.
BoxStream
A boxed stream for async iteration.
Incoming
Incoming connection stream.
LinkResult
Result type for link transport operations.