blob: dda7de9bd7d9d239bcc9bb52f9bc54800520bd30 (
plain)
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
|
/// Creates a new result type that returns the given result variant on error.
#[macro_export]
macro_rules! ffi_error {
($result:ident, $error:expr) => {
#[repr(C)]
#[derive(Debug)]
pub struct $result {
success: bool,
}
impl $result {
pub fn into_result(self) -> Result<(), Error> {
match self.success {
true => Ok(()),
false => Err($error),
}
}
}
impl From<$result> for Result<(), Error> {
fn from(result: $result) -> Self {
result.into_result()
}
}
};
}
|