error_repr/
lib.rs

1#![cfg_attr(not(any(feature = "std", test)), no_std)]
2#![deny(missing_docs)]
3//! A crate that generlizes the API surface of [`std::io::Error`] by providing a type that wraps an error kind and a payload.
4//!
5//! ## Features
6//! * `alloc`: Adds support for interfaces that require an allocator. In particular, this adds error constructors that take arbitrary payloads.
7//! * `std`: Adds support for interfaces that require the standard library (conversions to and from [`std::io::Error`] and an implementing [`kind::ErrorKind`] for [`std::io::ErrorKind`]).
8//! * `error-track_caller`: Causes construction of [`Error`] to carry information about the location they were created.
9//!     This is a debugging tool only - it does not add any API interfaces to the crate. Instead, the error simply holds the information internally, which is shown in the [`core::fmt::Debug`] impl.
10//!
11//!
12#![cfg_attr(
13    all(not(feature = "std"), doc),
14    doc = "[`std::io::Error`]: <https://doc.rust-lang.org/std/io/struct.Error.html>"
15)]
16#![cfg_attr(
17    all(not(feature = "std"), doc),
18    doc = "[`std::io::ErrorKind`]: <https://doc.rust-lang.org/std/io/enum.ErrorKind.html>"
19)]
20
21mod error;
22/// Module for the [`ErrorKind`][kind::ErrorKind] trait and support traits.
23pub mod kind;
24
25pub use error::Error;
26
27#[cfg(feature = "alloc")]
28extern crate alloc;
29
30cfg_match::cfg_match! {
31    any(target_os = "lilium") => {
32        /// The raw type of an OS Error.
33        /// On most targets, this is `i32`, but on other targets it may be `isize` or another integer type
34        pub type RawOsError = isize;
35    }
36    _ => {
37        /// The raw type of an OS Error.
38        /// On most targets, this is `i32`, but on other targets it may be `isize` or another integer type
39        pub type RawOsError = i32;
40    }
41}