u32err 0.1.1

A neat error type for FFI functions (where non-zero = failure)
Documentation
  • Coverage
  • 14.29%
    1 out of 7 items documented1 out of 7 items with examples
  • Size
  • Source code size: 5.88 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.07 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • Homepage
  • Wazzaps/u32err
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Wazzaps

u32err

This crate implements the core::ops::Try trait with a thin wrapper over u32.

You may use it to implement ergonomic error handling for FFI functions that return non-zero values on failure, or as a lightweight Result.

Example

use u32err::ErrCode;
extern "C" {
    /// This is a function that does something (via FFI).
    ///
    /// It returns either a 0 on success, or a non-zero number on failure.
    /// The real FFI signature of this function returns [`u32`], but the types are compatible.
    fn returns_zero_on_success() -> ErrCode;
}

fn foo() -> ErrCode {
    unsafe {
        returns_zero_on_success()?;
    }
    ErrCode(0)
}