|
1 | | -#![allow(non_upper_case_globals)] |
2 | | -#![allow(non_camel_case_types)] |
3 | | -#![allow(non_snake_case)] |
4 | | -#![allow(unused)] |
5 | | -#![allow(clippy::all)] |
6 | | - |
7 | | -#[must_use] |
8 | | -#[repr(transparent)] |
9 | | -#[derive(Clone, Copy, PartialEq, Eq)] |
10 | | -pub struct OfxStatus(pub std::ffi::c_int); |
11 | | - |
12 | | -impl std::fmt::Debug for OfxStatus { |
13 | | - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
14 | | - match self.0 { |
15 | | - 0 => f.write_str("kOfxStatOK"), |
16 | | - 1 => f.write_str("kOfxStatFailed"), |
17 | | - 2 => f.write_str("kOfxStatErrFatal"), |
18 | | - 3 => f.write_str("kOfxStatErrUnknown"), |
19 | | - 4 => f.write_str("kOfxStatErrMissingHostFeature"), |
20 | | - 5 => f.write_str("kOfxStatErrUnsupported"), |
21 | | - 6 => f.write_str("kOfxStatErrExists"), |
22 | | - 7 => f.write_str("kOfxStatErrFormat"), |
23 | | - 8 => f.write_str("kOfxStatErrMemory"), |
24 | | - 9 => f.write_str("kOfxStatErrBadHandle"), |
25 | | - 10 => f.write_str("kOfxStatErrBadIndex"), |
26 | | - 11 => f.write_str("kOfxStatErrValue"), |
27 | | - 12 => f.write_str("kOfxStatReplyYes"), |
28 | | - 13 => f.write_str("kOfxStatReplyNo"), |
29 | | - 14 => f.write_str("kOfxStatReplyDefault"), |
30 | | - _ => f.debug_tuple("OfxStatus").field(&self.0).finish(), |
31 | | - } |
32 | | - } |
33 | | -} |
34 | | - |
35 | | -impl From<std::ffi::c_int> for OfxStatus { |
36 | | - fn from(value: std::ffi::c_int) -> Self { |
37 | | - Self(value) |
38 | | - } |
39 | | -} |
40 | | - |
41 | | -// bindgen can't import these |
42 | | -#[allow(dead_code)] |
43 | | -pub mod OfxStat { |
44 | | - use crate::bindings::OfxStatus; |
45 | | - |
46 | | - pub const kOfxStatOK: OfxStatus = OfxStatus(0); |
47 | | - pub const kOfxStatFailed: OfxStatus = OfxStatus(1); |
48 | | - pub const kOfxStatErrFatal: OfxStatus = OfxStatus(2); |
49 | | - pub const kOfxStatErrUnknown: OfxStatus = OfxStatus(3); |
50 | | - pub const kOfxStatErrMissingHostFeature: OfxStatus = OfxStatus(4); |
51 | | - pub const kOfxStatErrUnsupported: OfxStatus = OfxStatus(5); |
52 | | - pub const kOfxStatErrExists: OfxStatus = OfxStatus(6); |
53 | | - pub const kOfxStatErrFormat: OfxStatus = OfxStatus(7); |
54 | | - pub const kOfxStatErrMemory: OfxStatus = OfxStatus(8); |
55 | | - pub const kOfxStatErrBadHandle: OfxStatus = OfxStatus(9); |
56 | | - pub const kOfxStatErrBadIndex: OfxStatus = OfxStatus(10); |
57 | | - pub const kOfxStatErrValue: OfxStatus = OfxStatus(11); |
58 | | - pub const kOfxStatReplyYes: OfxStatus = OfxStatus(12); |
59 | | - pub const kOfxStatReplyNo: OfxStatus = OfxStatus(13); |
60 | | - pub const kOfxStatReplyDefault: OfxStatus = OfxStatus(14); |
61 | | -} |
62 | | - |
63 | | -include!(concat!(env!("OUT_DIR"), "/bindings.rs")); |
| 1 | +#![allow(non_upper_case_globals)] |
| 2 | +#![allow(non_camel_case_types)] |
| 3 | +#![allow(non_snake_case)] |
| 4 | +#![allow(unused)] |
| 5 | +#![allow(clippy::all)] |
| 6 | + |
| 7 | +#[must_use] |
| 8 | +#[repr(transparent)] |
| 9 | +#[derive(Clone, Copy, PartialEq, Eq)] |
| 10 | +pub struct OfxStatus(pub std::ffi::c_int); |
| 11 | + |
| 12 | +impl OfxStatus { |
| 13 | + pub fn ofx_ok(self) -> OfxResult<()> { |
| 14 | + if self.0 == 0 { Ok(()) } else { Err(self) } |
| 15 | + } |
| 16 | +} |
| 17 | + |
| 18 | +impl std::fmt::Debug for OfxStatus { |
| 19 | + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
| 20 | + match self.0 { |
| 21 | + 0 => f.write_str("kOfxStatOK"), |
| 22 | + 1 => f.write_str("kOfxStatFailed"), |
| 23 | + 2 => f.write_str("kOfxStatErrFatal"), |
| 24 | + 3 => f.write_str("kOfxStatErrUnknown"), |
| 25 | + 4 => f.write_str("kOfxStatErrMissingHostFeature"), |
| 26 | + 5 => f.write_str("kOfxStatErrUnsupported"), |
| 27 | + 6 => f.write_str("kOfxStatErrExists"), |
| 28 | + 7 => f.write_str("kOfxStatErrFormat"), |
| 29 | + 8 => f.write_str("kOfxStatErrMemory"), |
| 30 | + 9 => f.write_str("kOfxStatErrBadHandle"), |
| 31 | + 10 => f.write_str("kOfxStatErrBadIndex"), |
| 32 | + 11 => f.write_str("kOfxStatErrValue"), |
| 33 | + 12 => f.write_str("kOfxStatReplyYes"), |
| 34 | + 13 => f.write_str("kOfxStatReplyNo"), |
| 35 | + 14 => f.write_str("kOfxStatReplyDefault"), |
| 36 | + _ => f.debug_tuple("OfxStatus").field(&self.0).finish(), |
| 37 | + } |
| 38 | + } |
| 39 | +} |
| 40 | + |
| 41 | +impl From<std::ffi::c_int> for OfxStatus { |
| 42 | + fn from(value: std::ffi::c_int) -> Self { |
| 43 | + Self(value) |
| 44 | + } |
| 45 | +} |
| 46 | + |
| 47 | +pub type OfxResult<T> = Result<T, OfxStatus>; |
| 48 | + |
| 49 | +// bindgen can't import these |
| 50 | +#[allow(dead_code)] |
| 51 | +pub mod OfxStat { |
| 52 | + use crate::bindings::OfxStatus; |
| 53 | + |
| 54 | + pub const kOfxStatOK: OfxStatus = OfxStatus(0); |
| 55 | + pub const kOfxStatFailed: OfxStatus = OfxStatus(1); |
| 56 | + pub const kOfxStatErrFatal: OfxStatus = OfxStatus(2); |
| 57 | + pub const kOfxStatErrUnknown: OfxStatus = OfxStatus(3); |
| 58 | + pub const kOfxStatErrMissingHostFeature: OfxStatus = OfxStatus(4); |
| 59 | + pub const kOfxStatErrUnsupported: OfxStatus = OfxStatus(5); |
| 60 | + pub const kOfxStatErrExists: OfxStatus = OfxStatus(6); |
| 61 | + pub const kOfxStatErrFormat: OfxStatus = OfxStatus(7); |
| 62 | + pub const kOfxStatErrMemory: OfxStatus = OfxStatus(8); |
| 63 | + pub const kOfxStatErrBadHandle: OfxStatus = OfxStatus(9); |
| 64 | + pub const kOfxStatErrBadIndex: OfxStatus = OfxStatus(10); |
| 65 | + pub const kOfxStatErrValue: OfxStatus = OfxStatus(11); |
| 66 | + pub const kOfxStatReplyYes: OfxStatus = OfxStatus(12); |
| 67 | + pub const kOfxStatReplyNo: OfxStatus = OfxStatus(13); |
| 68 | + pub const kOfxStatReplyDefault: OfxStatus = OfxStatus(14); |
| 69 | +} |
| 70 | + |
| 71 | +include!(concat!(env!("OUT_DIR"), "/bindings.rs")); |
0 commit comments