1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#![allow(non_camel_case_types)]
#![allow(overflowing_literals)]
pub type NTSTATUS = Status;
pub type Result<T> = ::core::result::Result<T, Status>;
#[repr(C)]
#[derive(Clone, Copy)]
pub enum Status {
success = 0,
unsuccessful = 0xC0000001,
}
impl Status {
pub fn is_ok(&self) -> bool {
(*self as i32) >= 0
}
pub fn is_err(&self) -> bool {
(*self as i32) < 0
}
pub fn is_success(&self) -> bool {
let c = *self as u32;
c > 0 && c < 0x3FFF_FFFF
}
pub fn is_information(&self) -> bool {
let c = *self as u32;
c > 0x4000_0000 && c < 0x7FFF_FFFF
}
pub fn is_warning(&self) -> bool {
let c = *self as u32;
c > 0x8000_0000 && c < 0xBFFF_FFFF
}
pub fn is_error(&self) -> bool {
let c = *self as u32;
c > 0xC000_0000 && c < 0xFFFF_FFFF
}
}
pub fn check(st: Status) -> Result<()> {
if st.is_err() {
Err(st)
} else {
Ok(())
}
}