Skip to main content

ringline_quic/
error.rs

1use std::io;
2
3use bytes::Bytes;
4use quinn_proto::{ConnectError, ConnectionError, ReadError, ReadableError, VarInt, WriteError};
5
6/// Errors returned by ringline-quic operations.
7///
8/// Marked `#[non_exhaustive]` because the crate is still evolving and new
9/// transport-layer error kinds are expected. Downstream `match` blocks must
10/// include a wildcard arm.
11#[derive(Debug, thiserror::Error)]
12#[non_exhaustive]
13pub enum Error {
14    #[error("connection closed")]
15    ConnectionClosed,
16
17    /// The connection has been locally closed but quinn-proto is still in
18    /// its draining window — distinguished from `ConnectionClosed` so
19    /// callers don't retry sends in a tight loop.
20    #[error("connection is closing")]
21    ConnectionClosing,
22
23    #[error("invalid connection")]
24    InvalidConnection,
25
26    #[error("connect: {0}")]
27    Connect(#[from] ConnectError),
28
29    #[error("connection: {0}")]
30    Connection(#[from] ConnectionError),
31
32    #[error("write: {0}")]
33    Write(#[from] WriteError),
34
35    #[error("read: {0}")]
36    Read(#[from] ReadError),
37
38    #[error("readable: {0}")]
39    Readable(#[from] ReadableError),
40
41    /// Operation targeted a stream that has already been finished, reset,
42    /// or stopped. Distinguished from connection-level closure so callers
43    /// can surface stream-scoped errors without tearing the connection.
44    #[error("stream is closed")]
45    StreamClosed,
46
47    /// Peer issued STOP_SENDING with the given application error code.
48    /// Surfaced from `stream_finish` (and any future send that races the
49    /// STOP) so the caller learns the application-defined reason.
50    #[error("peer stopped sending: code={}", .0.into_inner())]
51    StreamStopped(VarInt),
52
53    /// Datagrams are disabled by local transport config — sends will never
54    /// succeed on this connection.
55    #[error("datagrams disabled locally")]
56    DatagramDisabled,
57
58    /// Datagrams are disabled by the peer — sends will never succeed on
59    /// this connection.
60    #[error("datagrams unsupported by peer")]
61    DatagramUnsupportedByPeer,
62
63    /// Datagram payload exceeded the peer's `max_datagram_size`. Caller
64    /// must split or shrink.
65    #[error("datagram too large for peer")]
66    DatagramTooLarge,
67
68    /// The outgoing datagram buffer is full. `Bytes` carries back the
69    /// caller's original payload so it can be re-sent on the next
70    /// `QuicEvent::DatagramsUnblocked` without re-allocating.
71    #[error("datagram buffer blocked")]
72    DatagramBlocked(Bytes),
73
74    #[error("io: {0}")]
75    Io(#[from] io::Error),
76}