mod.rs

Overview

This file implements the MsQuic-based network transport layer providing QUIC protocol support. It defines the main transport struct MsQuicTransport and its associated connection and listener abstractions. The file handles connection establishment, listener creation, stream management, and data transmission over QUIC using the underlying msquic_async crate.

Key responsibilities include:

The file integrates with abstractions defined in other modules such as NetTransport, NetConnection, NetListener, and NetIncomingRequest traits, enabling modular network transport support. It also uses TLS credential and certificate identity concepts defined externally.


Modules and Imports


Constants


Structs and Implementations

MsQuicTransport


RegistrationWrapper


MsQuicListener


MsQuicNetIncomingRequest


MsQuicNetConnection


StreamPool


Functions

write_buffer_to_stream

read_message_from_stream

read_exact

resolve_bad_certificate


Interaction with Other Parts of the System


Usage Examples

Creating a Transport and Listener

let transport = MsQuicTransport::new();
let listener = transport.create_listener(bind_addr, &["my-alpn"], credential).await?;

Connecting to a Remote Peer

let connection = transport.connect(remote_addr, &["my-alpn"], credential).await?;

Accepting Incoming Connections

let incoming_request = listener.accept().await?;
let connection = incoming_request.accept().await?;

Sending and Receiving Data

connection.send(b"hello").await?;
let (data, duration) = connection.recv().await?;
println!("Received {} bytes in {:?}", data.len(), duration);

Important Implementation Details


Mermaid Diagram

classDiagram
class MsQuicTransport {
+Arc<RegistrationWrapper> registration
+new()
+create_listener()
+connect()
}
class RegistrationWrapper {
-Registration 0
+drop()
}
MsQuicTransport --> RegistrationWrapper : owns
class MsQuicListener {
-Listener instance
-String local_identity
+accept()
}
MsQuicTransport ..> MsQuicListener : creates
class MsQuicNetIncomingRequest {
-Connection connection
-String local_identity
+remote_addr()
+accept()
}
MsQuicListener ..> MsQuicNetIncomingRequest : accepts
class MsQuicNetConnection {
-Connection inner
-String local_identity
-String remote_identity
-Arc<StreamPool> stream_pool
+local_addr()
+remote_addr()
+send()
+recv()
+close()
+watch_close()
}
MsQuicNetIncomingRequest ..> MsQuicNetConnection : accepts
class StreamPool {
-Mutex<Option<SendStream>> send
-Mutex<Option<ReadStream>> recv
+acquire_send()
+acquire_recv()
}
MsQuicNetConnection --> StreamPool : owns