compio_quic/
lib.rs

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