objc2_security/generated/
SecPolicySearch.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::cell::UnsafeCell;
4use core::marker::{PhantomData, PhantomPinned};
5use core::ptr::NonNull;
6#[cfg(feature = "objc2")]
7use objc2::__framework_prelude::*;
8use objc2_core_foundation::*;
9
10use crate::*;
11
12/// A reference to an opaque policy search structure.
13///
14/// See also [Apple's documentation](https://developer.apple.com/documentation/security/secpolicysearch?language=objc)
15#[doc(alias = "SecPolicySearchRef")]
16#[repr(C)]
17pub struct SecPolicySearch {
18    inner: [u8; 0],
19    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
20}
21
22cf_type!(
23    unsafe impl SecPolicySearch {}
24);
25#[cfg(feature = "objc2")]
26cf_objc2_type!(
27    unsafe impl RefEncode<"OpaquePolicySearchRef"> for SecPolicySearch {}
28);
29
30unsafe impl ConcreteType for SecPolicySearch {
31    /// Returns the type identifier of SecPolicySearch instances.
32    ///
33    /// Returns: The CFTypeID of SecPolicySearch instances.
34    ///
35    /// This API is deprecated in 10.7. The SecPolicySearchRef type is no longer used.
36    #[doc(alias = "SecPolicySearchGetTypeID")]
37    #[inline]
38    fn type_id() -> CFTypeID {
39        extern "C-unwind" {
40            fn SecPolicySearchGetTypeID() -> CFTypeID;
41        }
42        unsafe { SecPolicySearchGetTypeID() }
43    }
44}
45
46impl SecPolicySearch {
47    /// Creates a search reference for finding a policy by specifying its object identifier.
48    ///
49    /// Parameter `certType`: The type of certificates a policy uses.
50    ///
51    /// Parameter `policyOID`: A pointer to a BER-encoded policy object identifier that uniquely specifies the policy.
52    ///
53    /// Parameter `value`: Unused.  Pass NULL for this value.  Use SecPolicySetValue to set per policy data.
54    ///
55    /// 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.
56    ///
57    /// Returns: A result code.  See "Security Error Codes" (SecBase.h).
58    ///
59    /// This function is deprecated in 10.7. To create a SecPolicyRef, use one of the SecPolicyCreate functions in SecPolicy.h.
60    ///
61    /// # Safety
62    ///
63    /// - `policy_oid` must be a valid pointer.
64    /// - `value` must be a valid pointer or null.
65    /// - `search_ref` must be a valid pointer.
66    #[doc(alias = "SecPolicySearchCreate")]
67    #[cfg(all(feature = "SecAsn1Types", feature = "cssmconfig", feature = "cssmtype"))]
68    #[deprecated]
69    #[inline]
70    pub unsafe fn create(
71        cert_type: CSSM_CERT_TYPE,
72        policy_oid: NonNull<SecAsn1Oid>,
73        value: *const SecAsn1Item,
74        search_ref: NonNull<*mut SecPolicySearch>,
75    ) -> OSStatus {
76        extern "C-unwind" {
77            fn SecPolicySearchCreate(
78                cert_type: CSSM_CERT_TYPE,
79                policy_oid: NonNull<SecAsn1Oid>,
80                value: *const SecAsn1Item,
81                search_ref: NonNull<*mut SecPolicySearch>,
82            ) -> OSStatus;
83        }
84        unsafe { SecPolicySearchCreate(cert_type, policy_oid, value, search_ref) }
85    }
86
87    /// Finds the next policy matching the given search criteria
88    ///
89    /// 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.
90    ///
91    /// Parameter `policyRef`: On return, a pointer to a policy reference.
92    ///
93    /// 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).
94    ///
95    /// This function is deprecated in 10.7. To create a SecPolicyRef, use one of the SecPolicyCreate functions in SecPolicy.h.
96    ///
97    /// # Safety
98    ///
99    /// `policy_ref` must be a valid pointer.
100    #[doc(alias = "SecPolicySearchCopyNext")]
101    #[cfg(feature = "SecBase")]
102    #[deprecated]
103    #[inline]
104    pub unsafe fn copy_next(&self, policy_ref: NonNull<*mut SecPolicy>) -> OSStatus {
105        extern "C-unwind" {
106            fn SecPolicySearchCopyNext(
107                search_ref: &SecPolicySearch,
108                policy_ref: NonNull<*mut SecPolicy>,
109            ) -> OSStatus;
110        }
111        unsafe { SecPolicySearchCopyNext(self, policy_ref) }
112    }
113}
114
115extern "C-unwind" {
116    #[cfg(all(feature = "SecAsn1Types", feature = "cssmconfig", feature = "cssmtype"))]
117    #[deprecated = "renamed to `SecPolicySearch::create`"]
118    pub fn SecPolicySearchCreate(
119        cert_type: CSSM_CERT_TYPE,
120        policy_oid: NonNull<SecAsn1Oid>,
121        value: *const SecAsn1Item,
122        search_ref: NonNull<*mut SecPolicySearch>,
123    ) -> OSStatus;
124}
125
126extern "C-unwind" {
127    #[cfg(feature = "SecBase")]
128    #[deprecated = "renamed to `SecPolicySearch::copy_next`"]
129    pub fn SecPolicySearchCopyNext(
130        search_ref: &SecPolicySearch,
131        policy_ref: NonNull<*mut SecPolicy>,
132    ) -> OSStatus;
133}