objc2-disk-arbitration 0.3.2

Bindings to the DiskArbitration framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::cell::UnsafeCell;
use core::ffi::*;
use core::marker::{PhantomData, PhantomPinned};
use core::ptr::NonNull;
#[cfg(feature = "objc2")]
use objc2::__framework_prelude::*;
use objc2_core_foundation::*;

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdareturnsuccess?language=objc)
pub const kDAReturnSuccess: c_int = 0;
/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdareturnerror?language=objc)
pub const kDAReturnError: c_int = -119930879;
/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdareturnbusy?language=objc)
pub const kDAReturnBusy: c_int = -119930878;
/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdareturnbadargument?language=objc)
pub const kDAReturnBadArgument: c_int = -119930877;
/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdareturnexclusiveaccess?language=objc)
pub const kDAReturnExclusiveAccess: c_int = -119930876;
/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdareturnnoresources?language=objc)
pub const kDAReturnNoResources: c_int = -119930875;
/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdareturnnotfound?language=objc)
pub const kDAReturnNotFound: c_int = -119930874;
/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdareturnnotmounted?language=objc)
pub const kDAReturnNotMounted: c_int = -119930873;
/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdareturnnotpermitted?language=objc)
pub const kDAReturnNotPermitted: c_int = -119930872;
/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdareturnnotprivileged?language=objc)
pub const kDAReturnNotPrivileged: c_int = -119930871;
/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdareturnnotready?language=objc)
pub const kDAReturnNotReady: c_int = -119930870;
/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdareturnnotwritable?language=objc)
pub const kDAReturnNotWritable: c_int = -119930869;
/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdareturnunsupported?language=objc)
pub const kDAReturnUnsupported: c_int = -119930868;

/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/dareturn?language=objc)
#[cfg(feature = "libc")]
pub type DAReturn = libc::mach_error_t;

/// Type of a reference to DADissenter instances.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/dadissenter?language=objc)
#[doc(alias = "DADissenterRef")]
#[repr(C)]
pub struct DADissenter {
    inner: [u8; 0],
    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
}

cf_type!(
    unsafe impl DADissenter {}
);
#[cfg(feature = "objc2")]
cf_objc2_type!(
    unsafe impl RefEncode<"__DADissenter"> for DADissenter {}
);

impl DADissenter {
    /// Creates a new dissenter object.
    ///
    /// Parameter `allocator`: The allocator object to be used to allocate memory.
    ///
    /// Parameter `status`: The return code.
    ///
    /// Parameter `string`: The return code string.  Pass NULL for no reason.
    ///
    /// Returns: A reference to a new DADissenter.
    #[doc(alias = "DADissenterCreate")]
    #[cfg(feature = "libc")]
    #[inline]
    pub unsafe fn new(
        allocator: Option<&CFAllocator>,
        status: DAReturn,
        string: Option<&CFString>,
    ) -> CFRetained<DADissenter> {
        extern "C-unwind" {
            fn DADissenterCreate(
                allocator: Option<&CFAllocator>,
                status: DAReturn,
                string: Option<&CFString>,
            ) -> Option<NonNull<DADissenter>>;
        }
        let ret = unsafe { DADissenterCreate(allocator, status, string) };
        let ret =
            ret.expect("function was marked as returning non-null, but actually returned NULL");
        unsafe { CFRetained::from_raw(ret) }
    }

    /// Obtains the return code.
    ///
    /// Parameter `dissenter`: The DADissenter for which to obtain the return code.
    ///
    /// Returns: The return code.  A BSD return code, if applicable, is encoded with unix_err().
    #[doc(alias = "DADissenterGetStatus")]
    #[cfg(feature = "libc")]
    #[inline]
    pub unsafe fn status(&self) -> DAReturn {
        extern "C-unwind" {
            fn DADissenterGetStatus(dissenter: &DADissenter) -> DAReturn;
        }
        unsafe { DADissenterGetStatus(self) }
    }

    /// Obtains the return code string.
    ///
    /// Parameter `dissenter`: The DADissenter for which to obtain the return code string.
    ///
    /// Returns: The return code string.
    #[doc(alias = "DADissenterGetStatusString")]
    #[inline]
    pub unsafe fn status_string(&self) -> Option<CFRetained<CFString>> {
        extern "C-unwind" {
            fn DADissenterGetStatusString(dissenter: &DADissenter) -> Option<NonNull<CFString>>;
        }
        let ret = unsafe { DADissenterGetStatusString(self) };
        ret.map(|ret| unsafe { CFRetained::retain(ret) })
    }
}

#[cfg(feature = "libc")]
#[deprecated = "renamed to `DADissenter::new`"]
#[inline]
pub unsafe extern "C-unwind" fn DADissenterCreate(
    allocator: Option<&CFAllocator>,
    status: DAReturn,
    string: Option<&CFString>,
) -> CFRetained<DADissenter> {
    extern "C-unwind" {
        fn DADissenterCreate(
            allocator: Option<&CFAllocator>,
            status: DAReturn,
            string: Option<&CFString>,
        ) -> Option<NonNull<DADissenter>>;
    }
    let ret = unsafe { DADissenterCreate(allocator, status, string) };
    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
    unsafe { CFRetained::from_raw(ret) }
}

extern "C-unwind" {
    #[cfg(feature = "libc")]
    #[deprecated = "renamed to `DADissenter::status`"]
    pub fn DADissenterGetStatus(dissenter: &DADissenter) -> DAReturn;
}

#[deprecated = "renamed to `DADissenter::status_string`"]
#[inline]
pub unsafe extern "C-unwind" fn DADissenterGetStatusString(
    dissenter: &DADissenter,
) -> Option<CFRetained<CFString>> {
    extern "C-unwind" {
        fn DADissenterGetStatusString(dissenter: &DADissenter) -> Option<NonNull<CFString>>;
    }
    let ret = unsafe { DADissenterGetStatusString(dissenter) };
    ret.map(|ret| unsafe { CFRetained::retain(ret) })
}