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

#874 in Rust patterns

Download history 21/week @ 2024-09-18 16/week @ 2024-09-25 6/week @ 2024-10-02 2/week @ 2024-10-09 1/week @ 2024-10-16 2/week @ 2024-10-30 2/week @ 2024-11-06 6/week @ 2024-11-13 12/week @ 2024-11-20 8/week @ 2024-11-27 16/week @ 2024-12-04 131/week @ 2024-12-11 38/week @ 2024-12-18

179 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