objc2_security/generated/
SecIdentitySearch.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/// Contains information about an identity search.
13///
14/// See also [Apple's documentation](https://developer.apple.com/documentation/security/secidentitysearch?language=objc)
15#[doc(alias = "SecIdentitySearchRef")]
16#[repr(C)]
17pub struct SecIdentitySearch {
18    inner: [u8; 0],
19    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
20}
21
22cf_type!(
23    unsafe impl SecIdentitySearch {}
24);
25#[cfg(feature = "objc2")]
26cf_objc2_type!(
27    unsafe impl RefEncode<"OpaqueSecIdentitySearchRef"> for SecIdentitySearch {}
28);
29
30unsafe impl ConcreteType for SecIdentitySearch {
31    /// Returns the type identifier of SecIdentitySearch instances.
32    ///
33    /// Returns: The CFTypeID of SecIdentitySearch instances.
34    ///
35    /// This API is deprecated in 10.7. The SecIdentitySearchRef type is no longer used.
36    #[doc(alias = "SecIdentitySearchGetTypeID")]
37    #[inline]
38    fn type_id() -> CFTypeID {
39        extern "C-unwind" {
40            fn SecIdentitySearchGetTypeID() -> CFTypeID;
41        }
42        unsafe { SecIdentitySearchGetTypeID() }
43    }
44}
45
46impl SecIdentitySearch {
47    /// Creates a search reference for finding identities.
48    ///
49    /// 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.
50    ///
51    /// Parameter `keyUsage`: A CSSM_KEYUSE value, as defined in cssmtype.h. This value narrows the search to return only those identities which match the specified key usage. Pass a value of 0 to ignore key usage and return all available identities. Note that passing CSSM_KEYUSE_ANY limits the results to only those identities that can be used for every operation.
52    ///
53    /// Parameter `searchRef`: On return, an identity search reference. You must release the identity search reference by calling the CFRelease function.
54    ///
55    /// Returns: A result code.  See "Security Error Codes" (SecBase.h).
56    ///
57    /// You can set values for key usage, and one or more keychains, to control the search for identities. You can use the returned search reference to obtain the remaining identities in subsequent calls to the SecIentitySearchCopyNext function. You must release the identity search reference by calling the CFRelease function.
58    /// This function is deprecated in Mac OS X 10.7 and later; to find identities which match a given key usage or other attributes, please use the SecItemCopyMatching API (see SecItem.h).
59    ///
60    /// # Safety
61    ///
62    /// - `keychain_or_array` should be of the correct type.
63    /// - `search_ref` must be a valid pointer or null.
64    #[doc(alias = "SecIdentitySearchCreate")]
65    #[cfg(all(feature = "cssmconfig", feature = "cssmtype"))]
66    #[deprecated]
67    #[inline]
68    pub unsafe fn create(
69        keychain_or_array: Option<&CFType>,
70        key_usage: CSSM_KEYUSE,
71        search_ref: *mut *mut SecIdentitySearch,
72    ) -> OSStatus {
73        extern "C-unwind" {
74            fn SecIdentitySearchCreate(
75                keychain_or_array: Option<&CFType>,
76                key_usage: CSSM_KEYUSE,
77                search_ref: *mut *mut SecIdentitySearch,
78            ) -> OSStatus;
79        }
80        unsafe { SecIdentitySearchCreate(keychain_or_array, key_usage, search_ref) }
81    }
82
83    /// Finds the next identity matching the given search criteria, as previously specified by a call to SecIdentitySearchCreate or SecIdentitySearchCreateWithAttributes.
84    ///
85    /// Parameter `searchRef`: A reference to the current identity search. You create the identity search reference by calling either SecIdentitySearchCreate or SecIdentitySearchCreateWithAttributes.
86    ///
87    /// Parameter `identity`: On return, an identity reference for the next found identity, if any. You must call the CFRelease function when finished with the identity reference.
88    ///
89    /// Returns: A result code. When there are no more identities found that match the search criteria, errSecItemNotFound is returned. See "Security Error Codes" (SecBase.h).
90    ///
91    /// This function is deprecated in Mac OS X 10.7 and later; to find identities which match specified attributes, please use the SecItemCopyMatching API (see SecItem.h).
92    ///
93    /// # Safety
94    ///
95    /// `identity` must be a valid pointer or null.
96    #[doc(alias = "SecIdentitySearchCopyNext")]
97    #[cfg(feature = "SecBase")]
98    #[deprecated]
99    #[inline]
100    pub unsafe fn copy_next(&self, identity: *mut *mut SecIdentity) -> OSStatus {
101        extern "C-unwind" {
102            fn SecIdentitySearchCopyNext(
103                search_ref: &SecIdentitySearch,
104                identity: *mut *mut SecIdentity,
105            ) -> OSStatus;
106        }
107        unsafe { SecIdentitySearchCopyNext(self, identity) }
108    }
109}
110
111extern "C-unwind" {
112    #[cfg(all(feature = "cssmconfig", feature = "cssmtype"))]
113    #[deprecated = "renamed to `SecIdentitySearch::create`"]
114    pub fn SecIdentitySearchCreate(
115        keychain_or_array: Option<&CFType>,
116        key_usage: CSSM_KEYUSE,
117        search_ref: *mut *mut SecIdentitySearch,
118    ) -> OSStatus;
119}
120
121extern "C-unwind" {
122    #[cfg(feature = "SecBase")]
123    #[deprecated = "renamed to `SecIdentitySearch::copy_next`"]
124    pub fn SecIdentitySearchCopyNext(
125        search_ref: &SecIdentitySearch,
126        identity: *mut *mut SecIdentity,
127    ) -> OSStatus;
128}