rmp/
errors.rs

1//! Internal error handling code, shared between encoding and decoding.
2//!
3//! This is used mainly for backwards compatibility and abstraction over std/no_std.
4
5/// An alias to the "default" error handling type.
6///
7/// This is problematic because when working on `#[no_std]`, because there is no [`std::error::Error`] trait and also no [`std::io::Error`] type.
8///
9/// Furthermore, this doesn't abstract over the differences between different implementations of [`RmpRead`](crate::decode::RmpRead)/[`RmpWrite`](crate::encode::RmpWrite).
10///
11/// When working directly with bytes streams, the error type is actually [Infallible](core::convert::Infallible).
12///
13/// For these two reasons, this type is deprecated
14#[cfg(feature = "std")]
15#[deprecated(note = "Doesn't abstract over RmpRead/RmpWrite (or work on no_std), use RmpRead::Error/RmpWrite::Error and RmpReadErr/RmpWriteErr instead")]
16pub type Error = ::std::io::Error;
17
18#[cfg(not(feature = "std"))]
19#[deprecated(note = "Doesn't work meaningfully on no_std")]
20pub type Error = ::core::convert::Infallible;
21
22/// Internal type used to abstract over the [`std::error::Error`] trait
23///
24/// This is a nop in no-std environments.
25#[cfg(feature = "std")]
26#[doc(hidden)]
27pub trait MaybeErrBound: std::error::Error {}
28#[cfg(feature = "std")]
29impl<T: ?Sized + std::error::Error> MaybeErrBound for T {}
30#[cfg(not(feature = "std"))]
31#[doc(hidden)]
32pub trait MaybeErrBound {}
33#[cfg(not(feature = "std"))]
34impl<T: ?Sized> MaybeErrBound for T {}