use super::*;
#[derive(thiserror::Error)]
pub enum QuicTransportError<A: AddressResolver, S: StreamLayer, W: Wire> {
#[error("no private IP address found, and explicit IP not provided")]
NoPrivateIP,
#[error("at least one bind address is required")]
EmptyBindAddresses,
#[error("the ip {0} is blocked")]
BlockedIp(IpAddr),
#[error("failed to resize packet buffer {0}")]
ResizePacketBuffer(std::io::Error),
#[error("failed to start listener on {0}: {1}")]
Listen(SocketAddr, std::io::Error),
#[error("failed to create resolver: {0}")]
Resolver(A::Error),
#[error("failed to resolve address {addr}: {err}")]
Resolve {
addr: A::Address,
err: A::Error,
},
#[error(transparent)]
Label(#[from] LabelError),
#[error(transparent)]
Stream(S::Error),
#[error(transparent)]
IO(#[from] std::io::Error),
#[error("wire error: {0}")]
Wire(W::Error),
#[error("packet too large, the maximum packet can be sent is 65535, got {0}")]
PacketTooLarge(usize),
#[error("custom error: {0}")]
Custom(std::borrow::Cow<'static, str>),
#[cfg(feature = "compression")]
#[cfg_attr(docsrs, doc(cfg(feature = "compression")))]
#[error("compressor: {0}")]
Compressor(#[from] compressor::CompressorError),
#[error("computation task panic")]
#[cfg(feature = "compression")]
ComputationTaskFailed,
}
impl<A: AddressResolver, S: StreamLayer, W: Wire> core::fmt::Debug for QuicTransportError<A, S, W> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
core::fmt::Display::fmt(&self, f)
}
}
impl<A, S, W> TransportError for QuicTransportError<A, S, W>
where
A: AddressResolver,
A::Address: Send + Sync + 'static,
S: StreamLayer,
W: Wire,
{
fn is_remote_failure(&self) -> bool {
if let Self::Stream(e) = self {
e.is_remote_failure()
} else {
false
}
}
fn custom(err: std::borrow::Cow<'static, str>) -> Self {
Self::Custom(err)
}
}