29 releases

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

#11 in Operating systems

Download history 2391369/week @ 2024-10-22 2256384/week @ 2024-10-29 2254302/week @ 2024-11-05 2378570/week @ 2024-11-12 2381608/week @ 2024-11-19 2261107/week @ 2024-11-26 2660217/week @ 2024-12-03 2904681/week @ 2024-12-10 2435847/week @ 2024-12-17 1427690/week @ 2024-12-24 1771123/week @ 2024-12-31 2783902/week @ 2025-01-07 2795854/week @ 2025-01-14 2792519/week @ 2025-01-21 2853338/week @ 2025-01-28 2574830/week @ 2025-02-04

11,505,108 downloads per month
Used in 26,361 crates (209 directly)

MIT/Apache

16KB
296 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
~53K SLoC