objc2_execution_policy/generated/
EPDeveloperTool.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6
7use crate::*;
8
9/// [Apple's documentation](https://developer.apple.com/documentation/executionpolicy/epdevelopertoolstatus?language=objc)
10// NS_ENUM
11#[repr(transparent)]
12#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
13pub struct EPDeveloperToolStatus(pub NSInteger);
14impl EPDeveloperToolStatus {
15    #[doc(alias = "EPDeveloperToolStatusNotDetermined")]
16    pub const NotDetermined: Self = Self(0);
17    #[doc(alias = "EPDeveloperToolStatusRestricted")]
18    pub const Restricted: Self = Self(1);
19    #[doc(alias = "EPDeveloperToolStatusDenied")]
20    pub const Denied: Self = Self(2);
21    #[doc(alias = "EPDeveloperToolStatusAuthorized")]
22    pub const Authorized: Self = Self(3);
23}
24
25unsafe impl Encode for EPDeveloperToolStatus {
26    const ENCODING: Encoding = NSInteger::ENCODING;
27}
28
29unsafe impl RefEncode for EPDeveloperToolStatus {
30    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
31}
32
33extern_class!(
34    /// [Apple's documentation](https://developer.apple.com/documentation/executionpolicy/epdevelopertool?language=objc)
35    #[unsafe(super(NSObject))]
36    #[derive(Debug, PartialEq, Eq, Hash)]
37    pub struct EPDeveloperTool;
38);
39
40extern_conformance!(
41    unsafe impl NSObjectProtocol for EPDeveloperTool {}
42);
43
44impl EPDeveloperTool {
45    extern_methods!(
46        /// Initializes the object to manage the lifetime of the XPC connection.
47        ///
48        /// The XPC connection remains for the lifecycle of the object and deallocation is
49        /// required to trigger the teardown of the XPC connection.
50        #[unsafe(method(init))]
51        #[unsafe(method_family = init)]
52        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
53
54        /// The current authorization status of the current process.
55        /// - Returns: An EPDeveloperToolStatus indicating whether the current process has developer tool privileges.
56        #[unsafe(method(authorizationStatus))]
57        #[unsafe(method_family = none)]
58        pub unsafe fn authorizationStatus(&self) -> EPDeveloperToolStatus;
59
60        #[cfg(feature = "block2")]
61        /// Checks whether developer tool privileges are already available and if not
62        /// populates an entry in Settings for user approval.
63        ///
64        /// This method does not show any UI to the user or guide them towards Settings for approval, if necessary.
65        ///
66        /// - Parameter handler: A block called asynchronously with whether the privilege is available.
67        ///
68        /// > New info
69        /// > Concurrency Note: You can call this method from synchronous code using a completion handler,
70        /// > as shown on this page, or you can call it as an asynchronous method that has the
71        /// > following declaration:
72        /// >
73        /// > ```swift
74        /// > func requestAccess() async -> Bool
75        /// > ```
76        /// >
77        /// > For information about concurrency and asynchronous code in Swift, see
78        /// <doc
79        /// ://com.apple.documentation/documentation/swift/calling-objective-c-apis-asynchronously>.
80        #[unsafe(method(requestDeveloperToolAccessWithCompletionHandler:))]
81        #[unsafe(method_family = none)]
82        pub unsafe fn requestDeveloperToolAccessWithCompletionHandler(
83            &self,
84            handler: &block2::DynBlock<dyn Fn(Bool)>,
85        );
86    );
87}
88
89/// Methods declared on superclass `NSObject`.
90impl EPDeveloperTool {
91    extern_methods!(
92        #[unsafe(method(new))]
93        #[unsafe(method_family = new)]
94        pub unsafe fn new() -> Retained<Self>;
95    );
96}