objc2_disk_arbitration/generated/
DADissenter.rs1use core::cell::UnsafeCell;
4use core::ffi::*;
5use core::marker::{PhantomData, PhantomPinned};
6use core::ptr::NonNull;
7#[cfg(feature = "objc2")]
8use objc2::__framework_prelude::*;
9use objc2_core_foundation::*;
10
11use crate::*;
12
13pub const kDAReturnSuccess: c_int = 0;
15pub const kDAReturnError: c_int = -119930879;
17pub const kDAReturnBusy: c_int = -119930878;
19pub const kDAReturnBadArgument: c_int = -119930877;
21pub const kDAReturnExclusiveAccess: c_int = -119930876;
23pub const kDAReturnNoResources: c_int = -119930875;
25pub const kDAReturnNotFound: c_int = -119930874;
27pub const kDAReturnNotMounted: c_int = -119930873;
29pub const kDAReturnNotPermitted: c_int = -119930872;
31pub const kDAReturnNotPrivileged: c_int = -119930871;
33pub const kDAReturnNotReady: c_int = -119930870;
35pub const kDAReturnNotWritable: c_int = -119930869;
37pub const kDAReturnUnsupported: c_int = -119930868;
39
40#[cfg(feature = "libc")]
42pub type DAReturn = libc::mach_error_t;
43
44#[doc(alias = "DADissenterRef")]
48#[repr(C)]
49pub struct DADissenter {
50 inner: [u8; 0],
51 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
52}
53
54cf_type!(
55 unsafe impl DADissenter {}
56);
57#[cfg(feature = "objc2")]
58cf_objc2_type!(
59 unsafe impl RefEncode<"__DADissenter"> for DADissenter {}
60);
61
62impl DADissenter {
63 #[doc(alias = "DADissenterCreate")]
73 #[cfg(feature = "libc")]
74 #[inline]
75 pub unsafe fn new(
76 allocator: Option<&CFAllocator>,
77 status: DAReturn,
78 string: Option<&CFString>,
79 ) -> CFRetained<DADissenter> {
80 extern "C-unwind" {
81 fn DADissenterCreate(
82 allocator: Option<&CFAllocator>,
83 status: DAReturn,
84 string: Option<&CFString>,
85 ) -> Option<NonNull<DADissenter>>;
86 }
87 let ret = unsafe { DADissenterCreate(allocator, status, string) };
88 let ret =
89 ret.expect("function was marked as returning non-null, but actually returned NULL");
90 unsafe { CFRetained::from_raw(ret) }
91 }
92
93 #[doc(alias = "DADissenterGetStatus")]
99 #[cfg(feature = "libc")]
100 #[inline]
101 pub unsafe fn status(&self) -> DAReturn {
102 extern "C-unwind" {
103 fn DADissenterGetStatus(dissenter: &DADissenter) -> DAReturn;
104 }
105 unsafe { DADissenterGetStatus(self) }
106 }
107
108 #[doc(alias = "DADissenterGetStatusString")]
114 #[inline]
115 pub unsafe fn status_string(&self) -> Option<CFRetained<CFString>> {
116 extern "C-unwind" {
117 fn DADissenterGetStatusString(dissenter: &DADissenter) -> Option<NonNull<CFString>>;
118 }
119 let ret = unsafe { DADissenterGetStatusString(self) };
120 ret.map(|ret| unsafe { CFRetained::retain(ret) })
121 }
122}
123
124#[cfg(feature = "libc")]
125#[deprecated = "renamed to `DADissenter::new`"]
126#[inline]
127pub unsafe extern "C-unwind" fn DADissenterCreate(
128 allocator: Option<&CFAllocator>,
129 status: DAReturn,
130 string: Option<&CFString>,
131) -> CFRetained<DADissenter> {
132 extern "C-unwind" {
133 fn DADissenterCreate(
134 allocator: Option<&CFAllocator>,
135 status: DAReturn,
136 string: Option<&CFString>,
137 ) -> Option<NonNull<DADissenter>>;
138 }
139 let ret = unsafe { DADissenterCreate(allocator, status, string) };
140 let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
141 unsafe { CFRetained::from_raw(ret) }
142}
143
144extern "C-unwind" {
145 #[cfg(feature = "libc")]
146 #[deprecated = "renamed to `DADissenter::status`"]
147 pub fn DADissenterGetStatus(dissenter: &DADissenter) -> DAReturn;
148}
149
150#[deprecated = "renamed to `DADissenter::status_string`"]
151#[inline]
152pub unsafe extern "C-unwind" fn DADissenterGetStatusString(
153 dissenter: &DADissenter,
154) -> Option<CFRetained<CFString>> {
155 extern "C-unwind" {
156 fn DADissenterGetStatusString(dissenter: &DADissenter) -> Option<NonNull<CFString>>;
157 }
158 let ret = unsafe { DADissenterGetStatusString(dissenter) };
159 ret.map(|ret| unsafe { CFRetained::retain(ret) })
160}