compio_quic/
lib.rs

1//! QUIC implementation based on [`quinn-proto`].
2//!
3//! [`quinn-proto`]: https://docs.rs/quinn-proto
4
5#![cfg_attr(docsrs, feature(doc_cfg))]
6#![warn(missing_docs)]
7#![deny(rustdoc::broken_intra_doc_links)]
8#![doc(
9    html_logo_url = "https://github.com/compio-rs/compio-logo/raw/refs/heads/master/generated/colored-bold.svg"
10)]
11#![doc(
12    html_favicon_url = "https://github.com/compio-rs/compio-logo/raw/refs/heads/master/generated/colored-bold.svg"
13)]
14
15pub use quinn_proto::{
16    AckFrequencyConfig, ApplicationClose, Chunk, ClientConfig, ClosedStream, ConfigError,
17    ConnectError, ConnectionClose, ConnectionStats, EndpointConfig, IdleTimeout,
18    MtuDiscoveryConfig, ServerConfig, StreamId, Transmit, TransportConfig, VarInt, congestion,
19    crypto,
20};
21
22#[cfg(rustls)]
23mod builder;
24mod connection;
25mod endpoint;
26mod incoming;
27mod recv_stream;
28mod send_stream;
29mod socket;
30
31#[cfg(rustls)]
32pub use builder::{ClientBuilder, ServerBuilder};
33pub use connection::{Connecting, Connection, ConnectionError};
34pub use endpoint::Endpoint;
35pub use incoming::{Incoming, IncomingFuture};
36pub use recv_stream::{ReadError, ReadExactError, RecvStream};
37pub use send_stream::{SendStream, WriteError};
38#[cfg(feature = "sync")]
39pub(crate) use synchrony::sync;
40#[cfg(not(feature = "sync"))]
41pub(crate) use synchrony::unsync as sync;
42
43pub(crate) use crate::{
44    connection::{ConnectionEvent, ConnectionInner},
45    endpoint::EndpointRef,
46    socket::*,
47};
48
49/// Errors from [`SendStream::stopped`] and [`RecvStream::stopped`].
50#[derive(Debug, thiserror::Error, Clone, PartialEq, Eq)]
51pub enum StoppedError {
52    /// The connection was lost
53    #[error("connection lost")]
54    ConnectionLost(#[from] ConnectionError),
55    /// This was a 0-RTT stream and the server rejected it
56    ///
57    /// Can only occur on clients for 0-RTT streams, which can be opened using
58    /// [`Connecting::into_0rtt()`].
59    ///
60    /// [`Connecting::into_0rtt()`]: crate::Connecting::into_0rtt()
61    #[error("0-RTT rejected")]
62    ZeroRttRejected,
63}
64
65impl From<StoppedError> for std::io::Error {
66    fn from(x: StoppedError) -> Self {
67        use StoppedError::*;
68        let kind = match x {
69            ZeroRttRejected => std::io::ErrorKind::ConnectionReset,
70            ConnectionLost(_) => std::io::ErrorKind::NotConnected,
71        };
72        Self::new(kind, x)
73    }
74}
75
76/// HTTP/3 support via [`h3`].
77#[cfg(feature = "h3")]
78pub mod h3 {
79    pub use h3::*;
80
81    pub use crate::{
82        connection::h3_impl::{BidiStream, OpenStreams},
83        send_stream::h3_impl::SendStream,
84    };
85}