Expand description
§Link Transport Abstraction Layer
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.
- Connection
Stats - Statistics for a connection.
- Protocol
Id - Protocol identifier for multiplexing multiple overlays on a single transport.
Enums§
- Disconnect
Reason - Reason for peer disconnection.
- Link
Error - Errors that can occur during link transport operations.
- Link
Event - Events emitted by the link transport layer.
- NatHint
- NAT type classification hint for connection strategy selection.
Traits§
- Link
Conn - A connection to a remote peer.
- Link
Recv Stream - A receive stream for reading data from a peer.
- Link
Send Stream - A send stream for writing data to a peer.
- Link
Transport - 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.
- Link
Result - Result type for link transport operations.