objc2-authentication-services 0.3.2

Bindings to the AuthenticationServices 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 objc2_foundation::*;

use crate::*;

/// Authorization state of an Apple ID credential.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/authenticationservices/asauthorizationappleidprovidercredentialstate?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct ASAuthorizationAppleIDProviderCredentialState(pub NSInteger);
impl ASAuthorizationAppleIDProviderCredentialState {
    #[doc(alias = "ASAuthorizationAppleIDProviderCredentialRevoked")]
    pub const Revoked: Self = Self(0);
    #[doc(alias = "ASAuthorizationAppleIDProviderCredentialAuthorized")]
    pub const Authorized: Self = Self(1);
    #[doc(alias = "ASAuthorizationAppleIDProviderCredentialNotFound")]
    pub const NotFound: Self = Self(2);
    #[doc(alias = "ASAuthorizationAppleIDProviderCredentialTransferred")]
    pub const Transferred: Self = Self(3);
}

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

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

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/authenticationservices/asauthorizationappleidprovidercredentialrevokednotification?language=objc)
    pub static ASAuthorizationAppleIDProviderCredentialRevokedNotification:
        &'static NSNotificationName;
}

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

#[cfg(feature = "ASAuthorizationProvider")]
extern_conformance!(
    unsafe impl ASAuthorizationProvider for ASAuthorizationAppleIDProvider {}
);

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

impl ASAuthorizationAppleIDProvider {
    extern_methods!(
        #[cfg(all(
            feature = "ASAuthorizationAppleIDRequest",
            feature = "ASAuthorizationOpenIDRequest",
            feature = "ASAuthorizationRequest"
        ))]
        /// This method initializes and returns an instance of
        ///
        /// See: ASAuthorizationAppleIDRequest to be serviced by
        ///
        /// See: ASAuthorizationController.
        #[unsafe(method(createRequest))]
        #[unsafe(method_family = none)]
        pub unsafe fn createRequest(&self) -> Retained<ASAuthorizationAppleIDRequest>;

        #[cfg(feature = "block2")]
        /// This method can be used to get the current state of an opaque user ID previously given.
        ///
        /// Parameter `userID`: Opaque user identifier that will be checked for state.
        ///
        /// Parameter `completion`: A completion block that will return one of 3 possible states
        ///
        /// See: ASAuthorizationAppleIDProviderCredentialState.
        ///
        ///
        /// Note: If credentialState is
        ///
        /// See: ASAuthorizationAppleIDProviderCredentialNotFound, an error will also be passed in the completion block.
        #[unsafe(method(getCredentialStateForUserID:completion:))]
        #[unsafe(method_family = none)]
        pub unsafe fn getCredentialStateForUserID_completion(
            &self,
            user_id: &NSString,
            completion: &block2::DynBlock<
                dyn Fn(ASAuthorizationAppleIDProviderCredentialState, *mut NSError),
            >,
        );
    );
}

/// Methods declared on superclass `NSObject`.
impl ASAuthorizationAppleIDProvider {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}