objc2_security/generated/SecRequirement.rs
1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4use objc2_core_foundation::*;
5
6use crate::*;
7
8#[cfg(feature = "CSCommon")]
9unsafe impl ConcreteType for SecRequirement {
10 /// Returns the type identifier of all SecRequirement instances.
11 #[doc(alias = "SecRequirementGetTypeID")]
12 #[inline]
13 fn type_id() -> CFTypeID {
14 extern "C-unwind" {
15 fn SecRequirementGetTypeID() -> CFTypeID;
16 }
17 unsafe { SecRequirementGetTypeID() }
18 }
19}
20
21#[cfg(feature = "CSCommon")]
22impl SecRequirement {
23 /// Create a SecRequirement object from binary form.
24 /// This is the effective inverse of SecRequirementCopyData.
25 ///
26 ///
27 /// Parameter `data`: A binary blob obtained earlier from a valid SecRequirement object
28 /// using the SecRequirementCopyData call. This is the only publicly supported
29 /// way to get such a data blob.
30 ///
31 /// Parameter `flags`: Optional flags. Pass kSecCSDefaultFlags for standard behavior.
32 ///
33 /// Parameter `requirement`: On successful return, contains a reference to a SecRequirement
34 /// object that behaves identically to the one the data blob was obtained from.
35 ///
36 /// Returns: Upon success, errSecSuccess. Upon error, an OSStatus value documented in
37 /// CSCommon.h or certain other Security framework headers.
38 ///
39 /// # Safety
40 ///
41 /// `requirement` must be a valid pointer.
42 #[doc(alias = "SecRequirementCreateWithData")]
43 #[cfg(feature = "CSCommon")]
44 #[inline]
45 pub unsafe fn create_with_data(
46 data: &CFData,
47 flags: SecCSFlags,
48 requirement: NonNull<*mut SecRequirement>,
49 ) -> OSStatus {
50 extern "C-unwind" {
51 fn SecRequirementCreateWithData(
52 data: &CFData,
53 flags: SecCSFlags,
54 requirement: NonNull<*mut SecRequirement>,
55 ) -> OSStatus;
56 }
57 unsafe { SecRequirementCreateWithData(data, flags, requirement) }
58 }
59
60 /// Create a SecRequirement object by compiling a valid text representation
61 /// of a requirement.
62 ///
63 ///
64 /// Parameter `text`: A CFString containing the text form of a (single) Code Requirement.
65 ///
66 /// Parameter `flags`: Optional flags. Pass kSecCSDefaultFlags for standard behavior.
67 ///
68 /// Parameter `requirement`: On successful return, contains a reference to a SecRequirement
69 /// object that implements the conditions described in text.
70 ///
71 /// Returns: Upon success, errSecSuccess. Upon error, an OSStatus value documented in
72 /// CSCommon.h or certain other Security framework headers.
73 ///
74 /// # Safety
75 ///
76 /// `requirement` must be a valid pointer.
77 #[doc(alias = "SecRequirementCreateWithString")]
78 #[cfg(feature = "CSCommon")]
79 #[inline]
80 pub unsafe fn create_with_string(
81 text: &CFString,
82 flags: SecCSFlags,
83 requirement: NonNull<*mut SecRequirement>,
84 ) -> OSStatus {
85 extern "C-unwind" {
86 fn SecRequirementCreateWithString(
87 text: &CFString,
88 flags: SecCSFlags,
89 requirement: NonNull<*mut SecRequirement>,
90 ) -> OSStatus;
91 }
92 unsafe { SecRequirementCreateWithString(text, flags, requirement) }
93 }
94
95 /// # Safety
96 ///
97 /// - `errors` must be a valid pointer or null.
98 /// - `requirement` must be a valid pointer.
99 #[doc(alias = "SecRequirementCreateWithStringAndErrors")]
100 #[cfg(feature = "CSCommon")]
101 #[inline]
102 pub unsafe fn create_with_string_and_errors(
103 text: &CFString,
104 flags: SecCSFlags,
105 errors: *mut *mut CFError,
106 requirement: NonNull<*mut SecRequirement>,
107 ) -> OSStatus {
108 extern "C-unwind" {
109 fn SecRequirementCreateWithStringAndErrors(
110 text: &CFString,
111 flags: SecCSFlags,
112 errors: *mut *mut CFError,
113 requirement: NonNull<*mut SecRequirement>,
114 ) -> OSStatus;
115 }
116 unsafe { SecRequirementCreateWithStringAndErrors(text, flags, errors, requirement) }
117 }
118
119 /// Extracts a stable, persistent binary form of a SecRequirement.
120 /// This is the effective inverse of SecRequirementCreateWithData.
121 ///
122 ///
123 /// Parameter `requirement`: A valid SecRequirement object.
124 ///
125 /// Parameter `flags`: Optional flags. Pass kSecCSDefaultFlags for standard behavior.
126 ///
127 /// Parameter `data`: On successful return, contains a reference to a CFData object
128 /// containing a binary blob that can be fed to SecRequirementCreateWithData
129 /// to recreate a SecRequirement object with identical behavior.
130 ///
131 /// Returns: Upon success, errSecSuccess. Upon error, an OSStatus value documented in
132 /// CSCommon.h or certain other Security framework headers.
133 ///
134 /// # Safety
135 ///
136 /// `data` must be a valid pointer.
137 #[doc(alias = "SecRequirementCopyData")]
138 #[cfg(feature = "CSCommon")]
139 #[inline]
140 pub unsafe fn copy_data(&self, flags: SecCSFlags, data: NonNull<*const CFData>) -> OSStatus {
141 extern "C-unwind" {
142 fn SecRequirementCopyData(
143 requirement: &SecRequirement,
144 flags: SecCSFlags,
145 data: NonNull<*const CFData>,
146 ) -> OSStatus;
147 }
148 unsafe { SecRequirementCopyData(self, flags, data) }
149 }
150
151 /// Converts a SecRequirement object into text form.
152 /// This is the effective inverse of SecRequirementCreateWithString.
153 ///
154 /// Repeated application of this function may produce text that differs in
155 /// formatting, may contain different source comments, and may perform its
156 /// validation functions in different order. However, it is guaranteed that
157 /// recompiling the text using SecRequirementCreateWithString will produce a
158 /// SecRequirement object that behaves identically to the one you start with.
159 ///
160 ///
161 /// Parameter `requirement`: A valid SecRequirement object.
162 ///
163 /// Parameter `flags`: Optional flags. Pass kSecCSDefaultFlags for standard behavior.
164 ///
165 /// Parameter `text`: On successful return, contains a reference to a CFString object
166 /// containing a text representation of the requirement.
167 ///
168 /// Returns: Upon success, errSecSuccess. Upon error, an OSStatus value documented in
169 /// CSCommon.h or certain other Security framework headers.
170 ///
171 /// # Safety
172 ///
173 /// `text` must be a valid pointer.
174 #[doc(alias = "SecRequirementCopyString")]
175 #[cfg(feature = "CSCommon")]
176 #[inline]
177 pub unsafe fn copy_string(
178 &self,
179 flags: SecCSFlags,
180 text: NonNull<*const CFString>,
181 ) -> OSStatus {
182 extern "C-unwind" {
183 fn SecRequirementCopyString(
184 requirement: &SecRequirement,
185 flags: SecCSFlags,
186 text: NonNull<*const CFString>,
187 ) -> OSStatus;
188 }
189 unsafe { SecRequirementCopyString(self, flags, text) }
190 }
191}
192
193extern "C-unwind" {
194 #[cfg(feature = "CSCommon")]
195 #[deprecated = "renamed to `SecRequirement::create_with_data`"]
196 pub fn SecRequirementCreateWithData(
197 data: &CFData,
198 flags: SecCSFlags,
199 requirement: NonNull<*mut SecRequirement>,
200 ) -> OSStatus;
201}
202
203extern "C-unwind" {
204 #[cfg(feature = "CSCommon")]
205 #[deprecated = "renamed to `SecRequirement::create_with_string`"]
206 pub fn SecRequirementCreateWithString(
207 text: &CFString,
208 flags: SecCSFlags,
209 requirement: NonNull<*mut SecRequirement>,
210 ) -> OSStatus;
211}
212
213extern "C-unwind" {
214 #[cfg(feature = "CSCommon")]
215 #[deprecated = "renamed to `SecRequirement::create_with_string_and_errors`"]
216 pub fn SecRequirementCreateWithStringAndErrors(
217 text: &CFString,
218 flags: SecCSFlags,
219 errors: *mut *mut CFError,
220 requirement: NonNull<*mut SecRequirement>,
221 ) -> OSStatus;
222}
223
224extern "C-unwind" {
225 #[cfg(feature = "CSCommon")]
226 #[deprecated = "renamed to `SecRequirement::copy_data`"]
227 pub fn SecRequirementCopyData(
228 requirement: &SecRequirement,
229 flags: SecCSFlags,
230 data: NonNull<*const CFData>,
231 ) -> OSStatus;
232}
233
234extern "C-unwind" {
235 #[cfg(feature = "CSCommon")]
236 #[deprecated = "renamed to `SecRequirement::copy_string`"]
237 pub fn SecRequirementCopyString(
238 requirement: &SecRequirement,
239 flags: SecCSFlags,
240 text: NonNull<*const CFString>,
241 ) -> OSStatus;
242}