objc2_security/generated/
SecTask.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/// CFType used for representing a task
13///
14/// See also [Apple's documentation](https://developer.apple.com/documentation/security/sectask?language=objc)
15#[doc(alias = "SecTaskRef")]
16#[repr(C)]
17pub struct SecTask {
18    inner: [u8; 0],
19    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
20}
21
22cf_type!(
23    unsafe impl SecTask {}
24);
25#[cfg(feature = "objc2")]
26cf_objc2_type!(
27    unsafe impl RefEncode<"__SecTask"> for SecTask {}
28);
29
30unsafe impl ConcreteType for SecTask {
31    /// Returns the type ID for CF instances of SecTask.
32    ///
33    /// Returns: A CFTypeID for SecTask
34    #[doc(alias = "SecTaskGetTypeID")]
35    #[inline]
36    fn type_id() -> CFTypeID {
37        extern "C-unwind" {
38            fn SecTaskGetTypeID() -> CFTypeID;
39        }
40        unsafe { SecTaskGetTypeID() }
41    }
42}
43
44impl SecTask {
45    /// Create a SecTask object for the current task.
46    ///
47    /// Returns: The newly created SecTask object or NULL on error.  The caller must
48    /// CFRelease the returned object.
49    #[doc(alias = "SecTaskCreateFromSelf")]
50    #[inline]
51    pub unsafe fn from_self(allocator: Option<&CFAllocator>) -> Option<CFRetained<SecTask>> {
52        extern "C-unwind" {
53            fn SecTaskCreateFromSelf(allocator: Option<&CFAllocator>) -> Option<NonNull<SecTask>>;
54        }
55        let ret = unsafe { SecTaskCreateFromSelf(allocator) };
56        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
57    }
58
59    /// Returns the value of a single entitlement for the represented
60    /// task.
61    ///
62    /// Parameter `task`: A previously created SecTask object
63    ///
64    /// Parameter `entitlement`: The name of the entitlement to be fetched
65    ///
66    /// Parameter `error`: On a NULL return, this may be contain a CFError describing
67    /// the problem.  This argument may be NULL if the caller is not interested in
68    /// detailed errors.
69    ///
70    /// Returns: The value of the specified entitlement for the process or NULL if
71    /// the entitlement value could not be retrieved.  The type of the returned
72    /// value will depend on the entitlement specified.  The caller must release
73    /// the returned object.
74    ///
75    /// A NULL return may indicate an error, or it may indicate that
76    /// the entitlement is simply not present.  In the latter case, no CFError is
77    /// returned.
78    ///
79    /// # Safety
80    ///
81    /// `error` must be a valid pointer or null.
82    #[doc(alias = "SecTaskCopyValueForEntitlement")]
83    #[inline]
84    pub unsafe fn value_for_entitlement(
85        &self,
86        entitlement: &CFString,
87        error: *mut *mut CFError,
88    ) -> Option<CFRetained<CFType>> {
89        extern "C-unwind" {
90            fn SecTaskCopyValueForEntitlement(
91                task: &SecTask,
92                entitlement: &CFString,
93                error: *mut *mut CFError,
94            ) -> Option<NonNull<CFType>>;
95        }
96        let ret = unsafe { SecTaskCopyValueForEntitlement(self, entitlement, error) };
97        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
98    }
99
100    /// Returns the values of multiple entitlements for the represented
101    /// task.
102    ///
103    /// Parameter `task`: A previously created SecTask object
104    ///
105    /// Parameter `entitlements`: An array of entitlement names to be fetched
106    ///
107    /// Parameter `error`: On a NULL return, this will contain a CFError describing
108    /// the problem.  This argument may be NULL if the caller is not interested in
109    /// detailed errors.  If a requested entitlement is not present for the
110    /// returned dictionary, the entitlement is not set on the task.  The caller
111    /// must CFRelease the returned value
112    ///
113    /// # Safety
114    ///
115    /// - `entitlements` generic must be of the correct type.
116    /// - `error` must be a valid pointer or null.
117    #[doc(alias = "SecTaskCopyValuesForEntitlements")]
118    #[inline]
119    pub unsafe fn values_for_entitlements(
120        &self,
121        entitlements: &CFArray,
122        error: *mut *mut CFError,
123    ) -> Option<CFRetained<CFDictionary>> {
124        extern "C-unwind" {
125            fn SecTaskCopyValuesForEntitlements(
126                task: &SecTask,
127                entitlements: &CFArray,
128                error: *mut *mut CFError,
129            ) -> Option<NonNull<CFDictionary>>;
130        }
131        let ret = unsafe { SecTaskCopyValuesForEntitlements(self, entitlements, error) };
132        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
133    }
134
135    /// Return the value of the codesigning identifier.
136    ///
137    /// Parameter `task`: A previously created SecTask object
138    ///
139    /// Parameter `error`: On a NULL return, this will contain a CFError describing
140    /// the problem.  This argument may be NULL if the caller is not interested in
141    /// detailed errors. The caller must CFRelease the returned value
142    ///
143    /// # Safety
144    ///
145    /// `error` must be a valid pointer or null.
146    #[doc(alias = "SecTaskCopySigningIdentifier")]
147    #[inline]
148    pub unsafe fn signing_identifier(
149        &self,
150        error: *mut *mut CFError,
151    ) -> Option<CFRetained<CFString>> {
152        extern "C-unwind" {
153            fn SecTaskCopySigningIdentifier(
154                task: &SecTask,
155                error: *mut *mut CFError,
156            ) -> Option<NonNull<CFString>>;
157        }
158        let ret = unsafe { SecTaskCopySigningIdentifier(self, error) };
159        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
160    }
161
162    /// Return the code sign status flags
163    ///
164    /// Parameter `task`: A previously created SecTask object
165    #[doc(alias = "SecTaskGetCodeSignStatus")]
166    #[inline]
167    pub unsafe fn code_sign_status(&self) -> u32 {
168        extern "C-unwind" {
169            fn SecTaskGetCodeSignStatus(task: &SecTask) -> u32;
170        }
171        unsafe { SecTaskGetCodeSignStatus(self) }
172    }
173}
174
175#[deprecated = "renamed to `SecTask::from_self`"]
176#[inline]
177pub unsafe extern "C-unwind" fn SecTaskCreateFromSelf(
178    allocator: Option<&CFAllocator>,
179) -> Option<CFRetained<SecTask>> {
180    extern "C-unwind" {
181        fn SecTaskCreateFromSelf(allocator: Option<&CFAllocator>) -> Option<NonNull<SecTask>>;
182    }
183    let ret = unsafe { SecTaskCreateFromSelf(allocator) };
184    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
185}
186
187#[deprecated = "renamed to `SecTask::value_for_entitlement`"]
188#[inline]
189pub unsafe extern "C-unwind" fn SecTaskCopyValueForEntitlement(
190    task: &SecTask,
191    entitlement: &CFString,
192    error: *mut *mut CFError,
193) -> Option<CFRetained<CFType>> {
194    extern "C-unwind" {
195        fn SecTaskCopyValueForEntitlement(
196            task: &SecTask,
197            entitlement: &CFString,
198            error: *mut *mut CFError,
199        ) -> Option<NonNull<CFType>>;
200    }
201    let ret = unsafe { SecTaskCopyValueForEntitlement(task, entitlement, error) };
202    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
203}
204
205#[deprecated = "renamed to `SecTask::values_for_entitlements`"]
206#[inline]
207pub unsafe extern "C-unwind" fn SecTaskCopyValuesForEntitlements(
208    task: &SecTask,
209    entitlements: &CFArray,
210    error: *mut *mut CFError,
211) -> Option<CFRetained<CFDictionary>> {
212    extern "C-unwind" {
213        fn SecTaskCopyValuesForEntitlements(
214            task: &SecTask,
215            entitlements: &CFArray,
216            error: *mut *mut CFError,
217        ) -> Option<NonNull<CFDictionary>>;
218    }
219    let ret = unsafe { SecTaskCopyValuesForEntitlements(task, entitlements, error) };
220    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
221}
222
223#[deprecated = "renamed to `SecTask::signing_identifier`"]
224#[inline]
225pub unsafe extern "C-unwind" fn SecTaskCopySigningIdentifier(
226    task: &SecTask,
227    error: *mut *mut CFError,
228) -> Option<CFRetained<CFString>> {
229    extern "C-unwind" {
230        fn SecTaskCopySigningIdentifier(
231            task: &SecTask,
232            error: *mut *mut CFError,
233        ) -> Option<NonNull<CFString>>;
234    }
235    let ret = unsafe { SecTaskCopySigningIdentifier(task, error) };
236    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
237}
238
239extern "C-unwind" {
240    #[deprecated = "renamed to `SecTask::code_sign_status`"]
241    pub fn SecTaskGetCodeSignStatus(task: &SecTask) -> u32;
242}