userspace/file/format/
result.rs1ample::result!(
2 Ok;
3 "Human Ok";
4 usize;
5 [
6 [1; USERSPACE_FILE_FORMAT_DEFAULT_OK; Default; usize; "ZE"; "Entry to ze"],
7 [2; USERSPACE_FILE_FORMAT_ELF_OK; Elf; crate::file::format::elf::Ok; "ZE"; "Entry to ze"],
8 ];
9 Error;
10 "Human error";
11 usize;
12 [
13 [1; USERSPACE_FILE_FORMAT_DEFAULT_ERROR; Default; usize; "ZE"; "Entry to ze"],
14 [2; USERSPACE_FILE_FORMAT_ELF_ERROR; Elf; crate::file::format::elf::Error; "ZE"; "Entry to ze"],
15 ]
16);
17
18impl Ok {
19 pub fn from_no(no: usize) -> Self {
20 Ok::Default(no)
21 }
22}
23
24impl Error {
25 pub fn from_no(no: usize) -> Self {
26 Error::Default(no)
27 }
28}
29
30pub type Result = core::result::Result<Ok, Error>;
31
32pub fn handle_result(result: usize) -> Result {
33 if (result as isize) < 0 {
34 Err(Error::from_no(result))
35 } else {
36 Ok(Ok::from_no(result))
37 }
38}