objc2-execution-policy 0.3.2

Bindings to the ExecutionPolicy framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/executionpolicy/epdevelopertoolstatus?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct EPDeveloperToolStatus(pub NSInteger);
impl EPDeveloperToolStatus {
    #[doc(alias = "EPDeveloperToolStatusNotDetermined")]
    pub const NotDetermined: Self = Self(0);
    #[doc(alias = "EPDeveloperToolStatusRestricted")]
    pub const Restricted: Self = Self(1);
    #[doc(alias = "EPDeveloperToolStatusDenied")]
    pub const Denied: Self = Self(2);
    #[doc(alias = "EPDeveloperToolStatusAuthorized")]
    pub const Authorized: Self = Self(3);
}

unsafe impl Encode for EPDeveloperToolStatus {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for EPDeveloperToolStatus {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/executionpolicy/epdevelopertool?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct EPDeveloperTool;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for EPDeveloperTool {}
);

impl EPDeveloperTool {
    extern_methods!(
        /// Initializes the object to manage the lifetime of the XPC connection.
        ///
        /// The XPC connection remains for the lifecycle of the object and deallocation is
        /// required to trigger the teardown of the XPC connection.
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        /// The current authorization status of the current process.
        /// - Returns: An EPDeveloperToolStatus indicating whether the current process has developer tool privileges.
        #[unsafe(method(authorizationStatus))]
        #[unsafe(method_family = none)]
        pub unsafe fn authorizationStatus(&self) -> EPDeveloperToolStatus;

        #[cfg(feature = "block2")]
        /// Checks whether developer tool privileges are already available and if not
        /// populates an entry in Settings for user approval.
        ///
        /// This method does not show any UI to the user or guide them towards Settings for approval, if necessary.
        ///
        /// - Parameter handler: A block called asynchronously with whether the privilege is available.
        ///
        /// > New info
        /// > Concurrency Note: You can call this method from synchronous code using a completion handler,
        /// > as shown on this page, or you can call it as an asynchronous method that has the
        /// > following declaration:
        /// >
        /// > ```swift
        /// > func requestAccess() async -> Bool
        /// > ```
        /// >
        /// > For information about concurrency and asynchronous code in Swift, see
        /// <doc
        /// ://com.apple.documentation/documentation/swift/calling-objective-c-apis-asynchronously>.
        #[unsafe(method(requestDeveloperToolAccessWithCompletionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn requestDeveloperToolAccessWithCompletionHandler(
            &self,
            handler: &block2::DynBlock<dyn Fn(Bool)>,
        );
    );
}

/// Methods declared on superclass `NSObject`.
impl EPDeveloperTool {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}