objc2_disk_arbitration/generated/
DADissenter.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use 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
13/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdareturnsuccess?language=objc)
14pub const kDAReturnSuccess: c_int = 0;
15/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdareturnerror?language=objc)
16pub const kDAReturnError: c_int = -119930879;
17/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdareturnbusy?language=objc)
18pub const kDAReturnBusy: c_int = -119930878;
19/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdareturnbadargument?language=objc)
20pub const kDAReturnBadArgument: c_int = -119930877;
21/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdareturnexclusiveaccess?language=objc)
22pub const kDAReturnExclusiveAccess: c_int = -119930876;
23/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdareturnnoresources?language=objc)
24pub const kDAReturnNoResources: c_int = -119930875;
25/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdareturnnotfound?language=objc)
26pub const kDAReturnNotFound: c_int = -119930874;
27/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdareturnnotmounted?language=objc)
28pub const kDAReturnNotMounted: c_int = -119930873;
29/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdareturnnotpermitted?language=objc)
30pub const kDAReturnNotPermitted: c_int = -119930872;
31/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdareturnnotprivileged?language=objc)
32pub const kDAReturnNotPrivileged: c_int = -119930871;
33/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdareturnnotready?language=objc)
34pub const kDAReturnNotReady: c_int = -119930870;
35/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdareturnnotwritable?language=objc)
36pub const kDAReturnNotWritable: c_int = -119930869;
37/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdareturnunsupported?language=objc)
38pub const kDAReturnUnsupported: c_int = -119930868;
39
40/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/dareturn?language=objc)
41#[cfg(feature = "libc")]
42pub type DAReturn = libc::mach_error_t;
43
44/// Type of a reference to DADissenter instances.
45///
46/// See also [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/dadissenter?language=objc)
47#[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    /// Creates a new dissenter object.
64    ///
65    /// Parameter `allocator`: The allocator object to be used to allocate memory.
66    ///
67    /// Parameter `status`: The return code.
68    ///
69    /// Parameter `string`: The return code string.  Pass NULL for no reason.
70    ///
71    /// Returns: A reference to a new DADissenter.
72    #[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    /// Obtains the return code.
94    ///
95    /// Parameter `dissenter`: The DADissenter for which to obtain the return code.
96    ///
97    /// Returns: The return code.  A BSD return code, if applicable, is encoded with unix_err().
98    #[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    /// Obtains the return code string.
109    ///
110    /// Parameter `dissenter`: The DADissenter for which to obtain the return code string.
111    ///
112    /// Returns: The return code string.
113    #[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}