28 releases

0.3.9 May 8, 2024
0.3.8 Nov 28, 2023
0.3.5 Oct 8, 2023
0.3.2 Jul 30, 2023
0.1.1 Mar 29, 2015

#16 in Operating systems

Download history 2173090/week @ 2024-07-21 2166408/week @ 2024-07-28 2141162/week @ 2024-08-04 2180860/week @ 2024-08-11 2244198/week @ 2024-08-18 2245522/week @ 2024-08-25 2187220/week @ 2024-09-01 2242970/week @ 2024-09-08 2113123/week @ 2024-09-15 2405936/week @ 2024-09-22 2521864/week @ 2024-09-29 2985473/week @ 2024-10-06 2824341/week @ 2024-10-13 2621256/week @ 2024-10-20 2271468/week @ 2024-10-27 2150844/week @ 2024-11-03

10,205,088 downloads per month
Used in 24,095 crates (200 directly)

MIT/Apache

16KB
294 lines

errno CI Cargo

Cross-platform interface to the errno variable. Works on Rust 1.56 or newer.

Documentation is available at https://docs.rs/errno.

Dependency

Add to your Cargo.toml:

[dependencies]
errno = "*"

Comparison with std::io::Error

The standard library provides Error::last_os_error which fetches errno in the same way.

This crate provides these extra features:

  • No heap allocations
  • Optional #![no_std] support
  • A set_errno function

Examples

extern crate errno;
use errno::{Errno, errno, set_errno};

// Get the current value of errno
let e = errno();

// Set the current value of errno
set_errno(e);

// Extract the error code as an i32
let code = e.0;

// Display a human-friendly error message
println!("Error {}: {}", code, e);

#![no_std]

Enable #![no_std] support by disabling the default std feature:

[dependencies]
errno = { version = "*", default-features = false }

The Error impl will be unavailable.

Dependencies

~0–8MB
~63K SLoC