objc2-security 0.3.2

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

use crate::*;

#[cfg(feature = "SecBase")]
unsafe impl ConcreteType for SecKeychainSearch {
    /// Returns the type identifier of SecKeychainSearch instances.
    ///
    /// Returns: The CFTypeID of SecKeychainSearch instances.
    ///
    /// This API is deprecated in 10.7. The SecKeychainSearchRef type is no longer used.
    #[doc(alias = "SecKeychainSearchGetTypeID")]
    #[inline]
    fn type_id() -> CFTypeID {
        extern "C-unwind" {
            fn SecKeychainSearchGetTypeID() -> CFTypeID;
        }
        unsafe { SecKeychainSearchGetTypeID() }
    }
}

#[cfg(feature = "SecBase")]
impl SecKeychainSearch {
    /// Creates a search reference matching a list of zero or more specified attributes in the specified keychain.
    ///
    /// Parameter `keychainOrArray`: An reference to an array of keychains to search, a single keychain or NULL to search the user's default keychain search list.
    ///
    /// Parameter `itemClass`: The keychain item class.
    ///
    /// Parameter `attrList`: A pointer to a list of zero or more keychain attribute records to match.  Pass NULL to match any keychain attribute.
    ///
    /// Parameter `searchRef`: On return, a pointer to the current search reference. You are responsible for calling the CFRelease function to release this reference when finished with it.
    ///
    /// Returns: A result code.  See "Security Error Codes" (SecBase.h).
    ///
    /// This function is deprecated in Mac OS X 10.7 and later; to find keychain items which match specified attributes, please use the SecItemCopyMatching API (see SecItem.h).
    ///
    /// # Safety
    ///
    /// - `keychain_or_array` should be of the correct type.
    /// - `attr_list` must be a valid pointer or null.
    /// - `search_ref` must be a valid pointer.
    #[doc(alias = "SecKeychainSearchCreateFromAttributes")]
    #[cfg(all(feature = "SecBase", feature = "SecKeychainItem"))]
    #[deprecated = "SecKeychainSearch is not supported"]
    #[inline]
    pub unsafe fn create_from_attributes(
        keychain_or_array: Option<&CFType>,
        item_class: SecItemClass,
        attr_list: *const SecKeychainAttributeList,
        search_ref: NonNull<*mut SecKeychainSearch>,
    ) -> OSStatus {
        extern "C-unwind" {
            fn SecKeychainSearchCreateFromAttributes(
                keychain_or_array: Option<&CFType>,
                item_class: SecItemClass,
                attr_list: *const SecKeychainAttributeList,
                search_ref: NonNull<*mut SecKeychainSearch>,
            ) -> OSStatus;
        }
        unsafe {
            SecKeychainSearchCreateFromAttributes(
                keychain_or_array,
                item_class,
                attr_list,
                search_ref,
            )
        }
    }

    /// Finds the next keychain item matching the given search criteria.
    ///
    /// Parameter `searchRef`: A reference to the current search criteria.  The search reference is created in the SecKeychainSearchCreateFromAttributes function and must be released by calling the CFRelease function when you are done with it.
    ///
    /// Parameter `itemRef`: On return, a pointer to a keychain item reference of the next matching keychain item, if any.
    ///
    /// Returns: A result code.  When there are no more items that match the parameters specified to SecPolicySearchCreate, errSecItemNotFound is returned. See "Security Error Codes" (SecBase.h).
    ///
    /// This function is deprecated in Mac OS X 10.7 and later; to find keychain items which match specified attributes, please use the SecItemCopyMatching API (see SecItem.h).
    ///
    /// # Safety
    ///
    /// `item_ref` must be a valid pointer.
    #[doc(alias = "SecKeychainSearchCopyNext")]
    #[cfg(feature = "SecBase")]
    #[deprecated = "SecKeychainSearch is not supported"]
    #[inline]
    pub unsafe fn copy_next(&self, item_ref: NonNull<*mut SecKeychainItem>) -> OSStatus {
        extern "C-unwind" {
            fn SecKeychainSearchCopyNext(
                search_ref: &SecKeychainSearch,
                item_ref: NonNull<*mut SecKeychainItem>,
            ) -> OSStatus;
        }
        unsafe { SecKeychainSearchCopyNext(self, item_ref) }
    }
}

extern "C-unwind" {
    #[cfg(all(feature = "SecBase", feature = "SecKeychainItem"))]
    #[deprecated = "renamed to `SecKeychainSearch::create_from_attributes`"]
    pub fn SecKeychainSearchCreateFromAttributes(
        keychain_or_array: Option<&CFType>,
        item_class: SecItemClass,
        attr_list: *const SecKeychainAttributeList,
        search_ref: NonNull<*mut SecKeychainSearch>,
    ) -> OSStatus;
}

extern "C-unwind" {
    #[cfg(feature = "SecBase")]
    #[deprecated = "renamed to `SecKeychainSearch::copy_next`"]
    pub fn SecKeychainSearchCopyNext(
        search_ref: &SecKeychainSearch,
        item_ref: NonNull<*mut SecKeychainItem>,
    ) -> OSStatus;
}