userspace/target/architecture/x86_64/
result.rs

1pub mod ok {
2    ample::result!( Ok; "Human Ok"; usize; [
3        [0; OK; Default; usize; "Ok"; "All good"],
4        [1; X86_64SYSCALL_OK; X86_64Syscall; super::super::syscall::Ok; "Ok"; "All good"],
5    ]);
6
7    impl Ok {
8        pub fn from_no(no: usize) -> Self {
9            Ok::Default(no)
10        }
11    }
12}
13
14// diferente
15pub mod error {
16    ample::result!(Error; "Human error"; usize; [
17        [1; ERROR; Default; usize; "Error"; "Something wicked this way comes"],
18        [0; OK; X86_64Syscall; super::super::syscall::Error; "Ok"; "All good"],
19    ]);
20
21    impl Error {
22        pub fn from_no(no: usize) -> Self {
23            Error::Default(no)
24        }
25    }
26}
27
28pub use error::Error;
29pub use ok::Ok;
30
31pub type Result = core::result::Result<Ok, Error>;
32
33pub fn handle_result(result: usize) -> crate::Result {
34    if (result as isize) < 0 {
35        core::result::Result::Err(crate::Error::Target(crate::target::Error::Arch(
36            Error::from_no(result),
37        )))
38    } else {
39        core::result::Result::Ok(crate::Ok::Target(crate::target::Ok::Arch(Ok::from_no(
40            result,
41        ))))
42    }
43}