Skip to main content

error_repr/
lib.rs

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