1type Filepath = *const u8;
2
3ample::result!(
4 Ok;
5 "Human Ok";
6 usize;
7 [
8 [1; USERSPACE_FILE_DEFAULT_OK; Default; usize; "ZE"; "Entry to ze"],
9 [2; USERSPACE_FILE_FILEPATH_OK; Filepath; Filepath; "ZE"; "Entry to ze"],
10 [3; USERSPACE_FILE_FORMAT_OK; Format; crate::file::format::Ok; "ZE"; "Entry to ze"],
11 ];
12 Error;
13 "Human error";
14 usize;
15 [
16 [1; USERSPACE_FILE_DEFAULT_ERROR; Default; usize; "ZE"; "Entry to ze"],
17 [3; USERSPACE_FILE_FORMAT_ERROR; Format; crate::file::format::Error; "ZE"; "Entry to ze"],
18 ]
19);
20
21impl Ok {
22 pub fn from_no(no: usize) -> Self {
23 Ok::Default(no)
24 }
25}
26
27impl Error {
28 pub fn from_no(no: usize) -> Self {
29 Error::Default(no)
30 }
31}
32
33pub type Result = core::result::Result<Ok, Error>;
34
35pub fn handle_result(result: usize) -> Result {
36 if (result as isize) < 0 {
37 Err(Error::from_no(result))
38 } else {
39 Ok(Ok::from_no(result))
40 }
41}