[][src]Crate quinn

QUIC transport protocol support for Tokio

QUIC is a modern transport protocol addressing shortcomings of TCP, such as head-of-line blocking, poor security, slow handshakes, and inefficient congestion control. This crate provides a portable userspace implementation.

The entry point of this crate is the Endpoint.

let mut runtime = tokio::runtime::Builder::new().basic_scheduler().enable_all().build().unwrap();
let mut builder = quinn::Endpoint::builder();
// <configure builder>
let (endpoint_driver, endpoint, _) = runtime.enter(|| builder.bind(&"[::]:0".parse().unwrap()).unwrap());
runtime.spawn(endpoint_driver.unwrap_or_else(|e| panic!("I/O error: {}", e)));
// <use endpoint>

About QUIC

A QUIC connection is an association between two endpoints. The endpoint which initiates the connection is termed the client, and the endpoint which accepts it is termed the server. A single endpoint may function as both client and server for different connections, for example in a peer-to-peer application. To communicate application data, each endpoint may open streams up to a limit dictated by its peer. Typically, that limit is increased as old streams are finished.

Streams may be unidirectional or bidirectional, and are cheap to create and disposable. For example, a traditionally datagram-oriented application could use a new stream for every message it wants to send, no longer needing to worry about MTUs. Bidirectional streams behave much like a traditional TCP connection, and are useful for sending messages that have an immediate response, such as an HTTP request. Stream data is delivered reliably, and there is no ordering enforced between data on different streams.

By avoiding head-of-line blocking and providing unified congestion control across all streams of a connection, QUIC is able to provide higher throughput and lower latency than one or multiple TCP connections between the same two hosts, while providing more useful behavior than raw UDP sockets.

QUIC uses encryption and identity verification built directly on TLS 1.3. Just as with a TLS server, it is useful for a QUIC server to be identified by a certificate signed by a trusted authority. If this is infeasible--for example, if servers are short-lived or not associated with a domain name--then as with TLS, self-signed certificates can be used to provide encryption alone.

Modules

crypto

Traits and implementations for the QUIC cryptography protocol

Structs

Certificate

A single TLS certificate

CertificateChain

A chain of signed TLS certificates ending the one to be used by a server

ClientConfigBuilder

Helper for creating new outgoing connections.

Connecting

In-progress connection attempt future

Connection

A QUIC connection.

ConnectionDriver

A future that drives protocol logic for a connection

ConnectionId

Protocol-level identifier for a connection.

Datagrams

Stream of unordered, unreliable datagrams sent by the peer

Endpoint

A QUIC endpoint.

EndpointBuilder

A helper for constructing an Endpoint.

EndpointDriver

A future that drives IO on an endpoint

Incoming

Stream of incoming connections.

IncomingBiStreams

A stream of bidirectional QUIC streams initiated by a remote peer.

IncomingUniStreams

A stream of unidirectional QUIC streams initiated by a remote peer.

NewConnection

Components of a newly established connection

OpenBi

A future that will resolve into an opened outgoing bidirectional stream

OpenUni

A future that will resolve into an opened outgoing unidirectional stream

ParseError

Errors encountered while parsing a TLS certificate or private key

PrivateKey

The private key of a TLS certificate to be used by a server

Read

Future produced by RecvStream::read

ReadExact

Future produced by RecvStream::read_exact

ReadToEnd

Future produced by read_to_end

RecvStream

A stream that can only be used to receive data

SendStream

A stream that can only be used to send data

ServerConfigBuilder

Helper for constructing a ServerConfig to be passed to EndpointBuilder::listen to enable incoming connections.

Transmit

An outgoing packet

TransportConfig

Parameters governing the core QUIC state machine

VarInt

An integer less than 2^62

Enums

ConnectError

Errors in the parameters being used to create a new connection

ConnectionError

Reasons why a connection might be lost.

DatagramEvent

Event resulting from processing a single datagram

EndpointError

Errors that can occur during the construction of an Endpoint.

ReadError

Errors that arise from reading from a stream.

ReadExactError

Errors that arise from reading from a stream.

ReadToEndError

Error from the ReadToEnd future

WriteError

Errors that arise from writing to a stream

Type Definitions

ClientConfig

A ClientConfig containing client-side rustls configuration

ServerConfig

A ServerConfig containing server-side rustls configuration