mod external_std;
mod external_third_parties;
mod internal;
#[cfg(feature = "asn1")]
use crate::asn1::Asn1Error;
use crate::{
calendar::CalendarError,
codec::{Base64Error, FromRadix10Error, HexError},
collections::{
ArrayStringError, ArrayVectorError, BlocksDequeError, DequeueError, FixedStringError,
ShortBoxStrU16, ShortStrU8, VectorError,
},
misc::{ArithmeticError, AsciiError},
};
#[allow(unused_imports, reason = "Depends on the selection of features")]
use alloc::boxed::Box;
use core::{
alloc::Layout,
array::TryFromSliceError,
convert::Infallible,
fmt::{Debug, Display, Formatter},
ops::RangeInclusive,
slice::GetDisjointMutError,
};
#[cfg(target_pointer_width = "64")]
const _: () = {
assert!(size_of::<Error>() <= 16);
};
macro_rules! associated_element_doc {
() => {
"See the documentation of the associated element."
};
}
#[derive(Debug)]
pub enum Error {
#[cfg(feature = "crypto-ruco")]
#[doc = associated_element_doc!()]
AeadError(aead::Error),
#[cfg(feature = "argon2")]
#[doc = associated_element_doc!()]
Argon2(argon2::Error),
#[cfg(feature = "crypto-ruco")]
#[doc = associated_element_doc!()]
CryptoCommonInvalidLength(crypto_common::InvalidLength),
#[cfg(feature = "crypto-ruco")]
#[doc = associated_element_doc!()]
EllipticCurveError(elliptic_curve::Error),
#[cfg(feature = "embassy-net")]
#[doc = associated_element_doc!()]
EmbassyNetTcp(embassy_net::tcp::Error),
#[cfg(feature = "embassy-net")]
#[doc = associated_element_doc!()]
EmbassyNetUdpBind(embassy_net::udp::BindError),
#[cfg(feature = "embassy-net")]
#[doc = associated_element_doc!()]
EmbassyNetUdpRecv(embassy_net::udp::RecvError),
#[cfg(feature = "embassy-net")]
#[doc = associated_element_doc!()]
EmbassyNetUdpSend(embassy_net::udp::SendError),
#[cfg(feature = "getrandom")]
#[doc = associated_element_doc!()]
GetRandomError(getrandom::Error),
#[cfg(feature = "crypto-graviola")]
#[doc = associated_element_doc!()]
GraviolaError(graviola::Error),
#[cfg(feature = "httparse")]
#[doc = associated_element_doc!()]
HttpParse(httparse::Error),
#[cfg(feature = "crypto-ruco")]
#[doc = associated_element_doc!()]
MacError(digest::MacError),
#[cfg(feature = "crypto-ruco")]
#[doc = associated_element_doc!()]
Pkcs8Error(Box<pkcs8::Error>),
#[cfg(feature = "quick-protobuf")]
#[doc = associated_element_doc!()]
QuickProtobuf(Box<quick_protobuf::Error>),
#[cfg(feature = "crypto-ruco")]
#[doc = associated_element_doc!()]
RsaError(Box<rsa::Error>),
#[cfg(feature = "serde")]
#[doc = associated_element_doc!()]
SerdeDeValue(Box<::serde::de::value::Error>),
#[cfg(feature = "serde_json")]
#[doc = associated_element_doc!()]
SerdeJson(serde_json::Error),
#[cfg(feature = "serde_json")]
#[doc = associated_element_doc!()]
SerdeJsonDeserialize(ShortBoxStrU16),
#[cfg(feature = "crypto-ruco")]
#[doc = associated_element_doc!()]
Signature(Box<signature::Error>),
#[cfg(feature = "crypto-ruco")]
#[doc = associated_element_doc!()]
SpkiError(Box<spki::Error>),
#[cfg(feature = "tokio")]
#[doc = associated_element_doc!()]
TokioJoinError(Box<tokio::task::JoinError>),
#[cfg(feature = "tracing-subscriber")]
#[doc = associated_element_doc!()]
TryInitError(Box<tracing_subscriber::util::TryInitError>),
#[cfg(feature = "std")]
#[doc = associated_element_doc!()]
TryLockError(std::sync::TryLockError<()>),
#[cfg(feature = "uuid")]
#[doc = associated_element_doc!()]
UuidError(Box<uuid::Error>),
#[cfg(feature = "zlib-rs")]
#[doc = associated_element_doc!()]
ZlibRsDeflateError(zlib_rs::DeflateError),
#[cfg(feature = "zlib-rs")]
#[doc = associated_element_doc!()]
ZlibRsInflateError(zlib_rs::InflateError),
#[doc = associated_element_doc!()]
AddrParseError(core::net::AddrParseError),
#[doc = associated_element_doc!()]
Fmt(core::fmt::Error),
#[doc = associated_element_doc!()]
GetDisjointMutError(GetDisjointMutError),
#[cfg(feature = "std")]
#[doc = associated_element_doc!()]
IoError(std::io::Error),
#[doc = associated_element_doc!()]
ParseIntError(core::num::ParseIntError),
#[doc = associated_element_doc!()]
RecvError(RecvError),
#[doc = associated_element_doc!()]
SendError(SendError<()>),
#[doc = associated_element_doc!()]
TryFromIntError(core::num::TryFromIntError),
#[doc = associated_element_doc!()]
TryFromSliceError(TryFromSliceError),
#[doc = associated_element_doc!()]
Utf8Error(Box<core::str::Utf8Error>),
#[cfg(feature = "std")]
VarIsNotPresent(ShortBoxStrU16),
#[cfg(feature = "std")]
VarIsNotUnicode(ShortBoxStrU16),
AllocError(Box<Layout>),
ClosedHttpConnection,
ClosedWebSocketConnection,
CounterWriterOverflow,
ExpiredFuture,
FuturePolledAfterFinalization,
Generic(ShortBoxStrU16),
GenericStatic(ShortStrU8<'static>),
InsufficientOptionCapacity,
InvalidPartitionedBufferBounds,
InvalidPpmValue,
InvalidUTF8,
InvalidUTF8Bound,
InvalidUri,
InvalidWeight,
MissingCaProviders,
MissingVar(ShortStrU8<'static>),
MissingVarQuote(ShortBoxStrU16),
MlockError,
MunlockError,
NoAvailableVars(ShortBoxStrU16),
NoInnerValue(ShortStrU8<'static>),
NonGraphicByte,
ProgrammingError,
UnboundedNumber {
expected: RangeInclusive<i32>,
received: i32,
},
UnexpectedBufferState,
UnexpectedBufferStateInCodec,
UnexpectedBytes {
length: u16,
ty: ShortStrU8<'static>,
},
UnexpectedStreamReadEOF,
UnexpectedStreamWriteEOF,
UnexpectedString {
length: usize,
},
UnexpectedUint {
identifier: ShortStrU8<'static>,
received: u16,
},
UnsupportedMlockPlatform,
UnsupportedOperation,
UriCanNotBeOverwritten,
UsizeConversionOverflow,
VectoredWriteOverflow,
#[doc = associated_element_doc!()]
ArithmeticError(ArithmeticError),
#[doc = associated_element_doc!()]
ArrayStringError(ArrayStringError),
#[doc = associated_element_doc!()]
ArrayVectorError(ArrayVectorError),
#[doc = associated_element_doc!()]
AsciiError(AsciiError),
#[cfg(feature = "asn1")]
#[doc = associated_element_doc!()]
Asn1Error(Asn1Error),
#[doc = associated_element_doc!()]
Base64Error(Base64Error),
#[doc = associated_element_doc!()]
BlocksQueueError(BlocksDequeError),
#[doc = associated_element_doc!()]
CalendarError(CalendarError),
#[cfg(feature = "client-api-framework")]
#[doc = associated_element_doc!()]
ClientApiFrameworkError(crate::client_api_framework::ClientApiFrameworkError),
#[doc = associated_element_doc!()]
CodecError(Box<crate::codec::CodecError>),
#[cfg(feature = "http-cookie")]
#[doc = associated_element_doc!()]
Cookie(crate::http::CookieError),
#[cfg(feature = "crypto")]
#[doc = associated_element_doc!()]
CryptoError(crate::crypto::CryptoError),
#[cfg(feature = "database")]
#[doc = associated_element_doc!()]
DatabaseError(crate::database::DatabaseError),
#[doc = associated_element_doc!()]
ExecutorError(crate::executor::ExecutorError),
#[doc = associated_element_doc!()]
FixedStringError(FixedStringError),
#[doc = associated_element_doc!()]
FromRadix10Error(FromRadix10Error),
#[doc = associated_element_doc!()]
HexError(HexError),
#[cfg(feature = "http")]
#[doc = associated_element_doc!()]
HttpError(crate::http::HttpError),
#[cfg(feature = "http2")]
Http2Error(crate::http2::Http2Error),
#[cfg(feature = "http2")]
Http2ErrorGoAway(crate::http2::Http2ErrorCode, crate::http2::Http2Error),
#[cfg(feature = "http2")]
Http2FlowControlError(crate::http2::Http2Error, u32),
#[doc = associated_element_doc!()]
NetReadBufferError(crate::stream::BufStreamReaderError),
#[cfg(feature = "postgres")]
#[doc = associated_element_doc!()]
PostgresDbError(Box<crate::database::client::postgres::DbError>),
#[cfg(feature = "postgres")]
#[doc = associated_element_doc!()]
PostgresError(crate::database::client::postgres::PostgresError),
#[doc = associated_element_doc!()]
QueueError(DequeueError),
#[cfg(feature = "http")]
#[doc = associated_element_doc!()]
RouterError(crate::http::RouterError),
#[cfg(feature = "schema-manager")]
#[doc = associated_element_doc!()]
SchemaManagerError(crate::database::schema_manager::SchemaManagerError),
#[cfg(feature = "http2-server-framework")]
#[doc = associated_element_doc!()]
ServerFrameworkError(crate::http::http2_server_framework::Http2ServerFrameworkError),
#[cfg(feature = "http-session")]
#[doc = associated_element_doc!()]
SessionError(crate::http::SessionError),
#[cfg(feature = "tls")]
#[doc = associated_element_doc!()]
TlsError(crate::tls::TlsError),
#[cfg(feature = "tls")]
#[doc = associated_element_doc!()]
TlsErrorFatal(crate::tls::TlsError, crate::tls::AlertDescription),
#[doc = associated_element_doc!()]
VectorError(VectorError),
#[cfg(feature = "web-socket")]
#[doc = associated_element_doc!()]
WebSocketError(crate::web_socket::WebSocketError),
#[cfg(feature = "x509")]
#[doc = associated_element_doc!()]
X509CvError(crate::x509::X509CvError),
#[cfg(feature = "x509")]
#[doc = associated_element_doc!()]
X509Error(crate::x509::X509Error),
}
impl Display for Error {
#[inline]
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
<Self as Debug>::fmt(self, f)
}
}
impl core::error::Error for Error {}
impl From<Infallible> for Error {
#[inline]
fn from(value: Infallible) -> Self {
match value {}
}
}
impl From<Error> for () {
#[inline]
fn from(_: Error) -> Self {}
}
#[derive(Clone, Copy, Debug)]
pub enum RecvError {
Empty,
Disconnected,
}
#[derive(Debug)]
pub enum SendError<T> {
Full(T),
Disconnected(T),
}
impl<T> SendError<T> {
#[inline]
pub fn simplify(self) -> SendError<()> {
match self {
SendError::Full(_) => SendError::Full(()),
SendError::Disconnected(_) => SendError::Disconnected(()),
}
}
}