6 releases

0.2.3 Dec 16, 2024
0.2.2 Aug 15, 2024
0.1.1 Dec 25, 2023
0.1.0 Aug 22, 2023

#896 in Rust patterns

Download history 36/week @ 2024-09-14 18/week @ 2024-09-21 14/week @ 2024-09-28 2/week @ 2024-10-12 1/week @ 2024-10-19 4/week @ 2024-11-02 11/week @ 2024-11-16 10/week @ 2024-11-23 8/week @ 2024-11-30 23/week @ 2024-12-07 147/week @ 2024-12-14 12/week @ 2024-12-21

182 downloads per month
Used in 4 crates (3 directly)

MIT/Apache

25KB
525 lines

hierr

原来的名字为hun_error. 包装OS的错误码, 统一错误码的查询和获取接口

版本更新说明

  1. 0.2.3版本: 支持mingw(target_os = "windows", target_env = "gnu"), 同linux.
  2. 0.2.2版本: 解决widows下无法正确输出中文信息的bug

接口和使用样例

1. fn errno() -> i32;
2. fn set_errno(i32);
3. fn errmsg(i32, &mut [u8]) -> &str;

封装i32为Error

Example

use hierr;

let err = hierr::Error::last();
println!("{}", err);

let mut buf = [0_u8; 64];
println!("{}: {}",  hierr::errno(), hierr::errmsg(hierr::errno(), &mut buf[..]));

hierr::set_errno(100);
let err = hierr::Error::last();
assert_eq!(err, 100.into());
assert_eq!(hierr::errno(), 100);

lib.rs:

包装OS的错误码, 统一错误码的查询和获取接口

  1. fn errno() -> i32;
  2. fn set_errno(i32);
  3. fn errmsg(i32, &mut [u8]) -> &str;

封装i32为Error

Example

use hierr;

hierr::set_errno(100);
let err = hierr::Error::last();

println!("{}", err);

let mut buf = [0_u8; 64];
println!("{}: {}",  hierr::errno(), hierr::errmsg(hierr::errno(), &mut buf[..]));

assert_eq!(err, 100.into());
assert_eq!(hierr::errno(), 100);

No runtime deps