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::cell::UnsafeCell;
use core::marker::{PhantomData, PhantomPinned};
use core::ptr::NonNull;
#[cfg(feature = "objc2")]
use objc2::__framework_prelude::*;
use objc2_core_foundation::*;

use crate::*;

/// A reference to an opaque policy search structure.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/security/secpolicysearch?language=objc)
#[doc(alias = "SecPolicySearchRef")]
#[repr(C)]
pub struct SecPolicySearch {
    inner: [u8; 0],
    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
}

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

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

impl SecPolicySearch {
    /// Creates a search reference for finding a policy by specifying its object identifier.
    ///
    /// Parameter `certType`: The type of certificates a policy uses.
    ///
    /// Parameter `policyOID`: A pointer to a BER-encoded policy object identifier that uniquely specifies the policy.
    ///
    /// Parameter `value`: Unused.  Pass NULL for this value.  Use SecPolicySetValue to set per policy data.
    ///
    /// Parameter `searchRef`: On return, a pointer to a policy search reference. The policy search reference is used for subsequent calls to the SecCopyNextPolicy function to obtain the remaining trust policies. You are responsible for releasing the search reference by calling the CFRelease function when finished with it.
    ///
    /// Returns: A result code.  See "Security Error Codes" (SecBase.h).
    ///
    /// This function is deprecated in 10.7. To create a SecPolicyRef, use one of the SecPolicyCreate functions in SecPolicy.h.
    ///
    /// # Safety
    ///
    /// - `policy_oid` must be a valid pointer.
    /// - `value` must be a valid pointer or null.
    /// - `search_ref` must be a valid pointer.
    #[doc(alias = "SecPolicySearchCreate")]
    #[cfg(all(feature = "SecAsn1Types", feature = "cssmconfig", feature = "cssmtype"))]
    #[deprecated]
    #[inline]
    pub unsafe fn create(
        cert_type: CSSM_CERT_TYPE,
        policy_oid: NonNull<SecAsn1Oid>,
        value: *const SecAsn1Item,
        search_ref: NonNull<*mut SecPolicySearch>,
    ) -> OSStatus {
        extern "C-unwind" {
            fn SecPolicySearchCreate(
                cert_type: CSSM_CERT_TYPE,
                policy_oid: NonNull<SecAsn1Oid>,
                value: *const SecAsn1Item,
                search_ref: NonNull<*mut SecPolicySearch>,
            ) -> OSStatus;
        }
        unsafe { SecPolicySearchCreate(cert_type, policy_oid, value, search_ref) }
    }

    /// Finds the next policy matching the given search criteria
    ///
    /// Parameter `searchRef`: A reference to the current policy search criteria.    You create the policy search  reference by a calling the SecPolicySearchCreate function. You are responsible for releasing the policy by calling the CFRelease function when finished with it.
    ///
    /// Parameter `policyRef`: On return, a pointer to a policy reference.
    ///
    /// Returns: A result code.  When there are no more policies that match the parameters specified to SecPolicySearchCreate, errSecPolicyNotFound is returned. See "Security Error Codes" (SecBase.h).
    ///
    /// This function is deprecated in 10.7. To create a SecPolicyRef, use one of the SecPolicyCreate functions in SecPolicy.h.
    ///
    /// # Safety
    ///
    /// `policy_ref` must be a valid pointer.
    #[doc(alias = "SecPolicySearchCopyNext")]
    #[cfg(feature = "SecBase")]
    #[deprecated]
    #[inline]
    pub unsafe fn copy_next(&self, policy_ref: NonNull<*mut SecPolicy>) -> OSStatus {
        extern "C-unwind" {
            fn SecPolicySearchCopyNext(
                search_ref: &SecPolicySearch,
                policy_ref: NonNull<*mut SecPolicy>,
            ) -> OSStatus;
        }
        unsafe { SecPolicySearchCopyNext(self, policy_ref) }
    }
}

extern "C-unwind" {
    #[cfg(all(feature = "SecAsn1Types", feature = "cssmconfig", feature = "cssmtype"))]
    #[deprecated = "renamed to `SecPolicySearch::create`"]
    pub fn SecPolicySearchCreate(
        cert_type: CSSM_CERT_TYPE,
        policy_oid: NonNull<SecAsn1Oid>,
        value: *const SecAsn1Item,
        search_ref: NonNull<*mut SecPolicySearch>,
    ) -> OSStatus;
}

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