objc2-core-foundation 0.3.2

Bindings to the CoreFoundation framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;

use crate::*;

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfpreferencesanyapplication?language=objc)
    pub static kCFPreferencesAnyApplication: &'static CFString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfpreferencescurrentapplication?language=objc)
    pub static kCFPreferencesCurrentApplication: &'static CFString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfpreferencesanyhost?language=objc)
    pub static kCFPreferencesAnyHost: &'static CFString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfpreferencescurrenthost?language=objc)
    pub static kCFPreferencesCurrentHost: &'static CFString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfpreferencesanyuser?language=objc)
    pub static kCFPreferencesAnyUser: &'static CFString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfpreferencescurrentuser?language=objc)
    pub static kCFPreferencesCurrentUser: &'static CFString;
}

#[inline]
pub extern "C-unwind" fn CFPreferencesCopyAppValue(
    key: &CFString,
    application_id: &CFString,
) -> Option<CFRetained<CFPropertyList>> {
    extern "C-unwind" {
        fn CFPreferencesCopyAppValue(
            key: &CFString,
            application_id: &CFString,
        ) -> Option<NonNull<CFPropertyList>>;
    }
    let ret = unsafe { CFPreferencesCopyAppValue(key, application_id) };
    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}

/// # Safety
///
/// `key_exists_and_has_valid_format` must be a valid pointer or null.
#[inline]
pub unsafe extern "C-unwind" fn CFPreferencesGetAppBooleanValue(
    key: &CFString,
    application_id: &CFString,
    key_exists_and_has_valid_format: *mut Boolean,
) -> bool {
    extern "C-unwind" {
        fn CFPreferencesGetAppBooleanValue(
            key: &CFString,
            application_id: &CFString,
            key_exists_and_has_valid_format: *mut Boolean,
        ) -> Boolean;
    }
    let ret = unsafe {
        CFPreferencesGetAppBooleanValue(key, application_id, key_exists_and_has_valid_format)
    };
    ret != 0
}

extern "C-unwind" {
    /// # Safety
    ///
    /// `key_exists_and_has_valid_format` must be a valid pointer or null.
    pub fn CFPreferencesGetAppIntegerValue(
        key: &CFString,
        application_id: &CFString,
        key_exists_and_has_valid_format: *mut Boolean,
    ) -> CFIndex;
}

extern "C-unwind" {
    /// # Safety
    ///
    /// `value` should be of the correct type.
    pub fn CFPreferencesSetAppValue(
        key: &CFString,
        value: Option<&CFPropertyList>,
        application_id: &CFString,
    );
}

#[inline]
pub extern "C-unwind" fn CFPreferencesAddSuitePreferencesToApp(
    application_id: &CFString,
    suite_id: &CFString,
) {
    extern "C-unwind" {
        fn CFPreferencesAddSuitePreferencesToApp(application_id: &CFString, suite_id: &CFString);
    }
    unsafe { CFPreferencesAddSuitePreferencesToApp(application_id, suite_id) }
}

#[inline]
pub extern "C-unwind" fn CFPreferencesRemoveSuitePreferencesFromApp(
    application_id: &CFString,
    suite_id: &CFString,
) {
    extern "C-unwind" {
        fn CFPreferencesRemoveSuitePreferencesFromApp(
            application_id: &CFString,
            suite_id: &CFString,
        );
    }
    unsafe { CFPreferencesRemoveSuitePreferencesFromApp(application_id, suite_id) }
}

#[inline]
pub extern "C-unwind" fn CFPreferencesAppSynchronize(application_id: &CFString) -> bool {
    extern "C-unwind" {
        fn CFPreferencesAppSynchronize(application_id: &CFString) -> Boolean;
    }
    let ret = unsafe { CFPreferencesAppSynchronize(application_id) };
    ret != 0
}

#[inline]
pub extern "C-unwind" fn CFPreferencesCopyValue(
    key: &CFString,
    application_id: &CFString,
    user_name: &CFString,
    host_name: &CFString,
) -> Option<CFRetained<CFPropertyList>> {
    extern "C-unwind" {
        fn CFPreferencesCopyValue(
            key: &CFString,
            application_id: &CFString,
            user_name: &CFString,
            host_name: &CFString,
        ) -> Option<NonNull<CFPropertyList>>;
    }
    let ret = unsafe { CFPreferencesCopyValue(key, application_id, user_name, host_name) };
    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}

#[cfg(all(feature = "CFArray", feature = "CFDictionary"))]
#[inline]
pub extern "C-unwind" fn CFPreferencesCopyMultiple(
    keys_to_fetch: Option<&CFArray>,
    application_id: &CFString,
    user_name: &CFString,
    host_name: &CFString,
) -> CFRetained<CFDictionary> {
    extern "C-unwind" {
        fn CFPreferencesCopyMultiple(
            keys_to_fetch: Option<&CFArray>,
            application_id: &CFString,
            user_name: &CFString,
            host_name: &CFString,
        ) -> Option<NonNull<CFDictionary>>;
    }
    let ret =
        unsafe { CFPreferencesCopyMultiple(keys_to_fetch, application_id, user_name, host_name) };
    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
    unsafe { CFRetained::from_raw(ret) }
}

extern "C-unwind" {
    /// # Safety
    ///
    /// `value` should be of the correct type.
    pub fn CFPreferencesSetValue(
        key: &CFString,
        value: Option<&CFPropertyList>,
        application_id: &CFString,
        user_name: &CFString,
        host_name: &CFString,
    );
}

extern "C-unwind" {
    /// # Safety
    ///
    /// - `keys_to_set` generics must be of the correct type.
    /// - `keys_to_remove` generic must be of the correct type.
    #[cfg(all(feature = "CFArray", feature = "CFDictionary"))]
    pub fn CFPreferencesSetMultiple(
        keys_to_set: Option<&CFDictionary>,
        keys_to_remove: Option<&CFArray>,
        application_id: &CFString,
        user_name: &CFString,
        host_name: &CFString,
    );
}

#[inline]
pub extern "C-unwind" fn CFPreferencesSynchronize(
    application_id: &CFString,
    user_name: &CFString,
    host_name: &CFString,
) -> bool {
    extern "C-unwind" {
        fn CFPreferencesSynchronize(
            application_id: &CFString,
            user_name: &CFString,
            host_name: &CFString,
        ) -> Boolean;
    }
    let ret = unsafe { CFPreferencesSynchronize(application_id, user_name, host_name) };
    ret != 0
}

#[cfg(feature = "CFArray")]
#[deprecated = "Unsupported API"]
#[inline]
pub extern "C-unwind" fn CFPreferencesCopyApplicationList(
    user_name: &CFString,
    host_name: &CFString,
) -> Option<CFRetained<CFArray>> {
    extern "C-unwind" {
        fn CFPreferencesCopyApplicationList(
            user_name: &CFString,
            host_name: &CFString,
        ) -> Option<NonNull<CFArray>>;
    }
    let ret = unsafe { CFPreferencesCopyApplicationList(user_name, host_name) };
    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}

#[cfg(feature = "CFArray")]
#[inline]
pub extern "C-unwind" fn CFPreferencesCopyKeyList(
    application_id: &CFString,
    user_name: &CFString,
    host_name: &CFString,
) -> Option<CFRetained<CFArray>> {
    extern "C-unwind" {
        fn CFPreferencesCopyKeyList(
            application_id: &CFString,
            user_name: &CFString,
            host_name: &CFString,
        ) -> Option<NonNull<CFArray>>;
    }
    let ret = unsafe { CFPreferencesCopyKeyList(application_id, user_name, host_name) };
    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}

#[inline]
pub extern "C-unwind" fn CFPreferencesAppValueIsForced(
    key: &CFString,
    application_id: &CFString,
) -> bool {
    extern "C-unwind" {
        fn CFPreferencesAppValueIsForced(key: &CFString, application_id: &CFString) -> Boolean;
    }
    let ret = unsafe { CFPreferencesAppValueIsForced(key, application_id) };
    ret != 0
}