30 releases

0.3.11 Apr 4, 2025
0.3.10 Nov 28, 2024
0.3.9 May 8, 2024
0.3.8 Nov 28, 2023
0.1.1 Mar 29, 2015

#5 in Operating systems

Download history 2913353/week @ 2025-01-10 2727290/week @ 2025-01-17 2806098/week @ 2025-01-24 2992696/week @ 2025-01-31 3227791/week @ 2025-02-07 3148155/week @ 2025-02-14 3426001/week @ 2025-02-21 3547010/week @ 2025-02-28 3709144/week @ 2025-03-07 3708667/week @ 2025-03-14 4258968/week @ 2025-03-21 3507866/week @ 2025-03-28 3994490/week @ 2025-04-04 3698401/week @ 2025-04-11 3439838/week @ 2025-04-18 3039914/week @ 2025-04-25

14,828,724 downloads per month
Used in 28,701 crates (212 directly)

MIT/Apache

17KB
300 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–7.5MB
~52K SLoC