userspace/target/operating_system/linux/
result.rs

1pub mod ok {
2    ample::result!(
3        Ok;
4        "Human Ok";
5        usize;
6        [
7            [0; LINUX_DEFAULT_OK; Default; usize; "ZE"; "Entry to ze"],
8            [1; LINUX_SYSCALL_OK; Syscall; super::super::syscall::Ok; "ZE"; "Entry to ze"],
9        ]
10    );
11
12    impl Ok {
13        pub fn from_no(no: usize) -> Self {
14            Ok::Default(no)
15        }
16    }
17}
18
19pub mod error {
20    ample::result!(
21        Error;
22        "Human error";
23        usize;
24        [
25            [0; LINUX_DEFAULT_ERROR; Default; usize; "ZE"; "Entry to ze"],
26            [1; LINUX_SYSCALL_ERROR; Syscall; super::super::syscall::Error; "ZE"; "Entry to ze"],
27        ]
28    );
29
30    impl Error {
31        pub fn from_no(no: usize) -> Self {
32            Error::Default(no)
33        }
34    }
35}
36
37pub use error::Error;
38pub use ok::Ok;
39
40pub type Result = core::result::Result<Ok, Error>;
41
42pub fn handle_result(result: usize) -> crate::Result {
43    if (result as isize) < 0 {
44        core::result::Result::Err(crate::Error::Target(crate::target::Error::Os(
45            Error::from_no(result),
46        )))
47    } else {
48        core::result::Result::Ok(crate::Ok::Target(crate::target::Ok::Os(Ok::from_no(
49            result,
50        ))))
51    }
52}