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::*;

extern_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/authenticationservices/aswebauthenticationsessionrequestdelegate?language=objc)
    pub unsafe trait ASWebAuthenticationSessionRequestDelegate: NSObjectProtocol {
        #[optional]
        #[unsafe(method(authenticationSessionRequest:didCompleteWithCallbackURL:))]
        #[unsafe(method_family = none)]
        unsafe fn authenticationSessionRequest_didCompleteWithCallbackURL(
            &self,
            authentication_session_request: &ASWebAuthenticationSessionRequest,
            callback_url: &NSURL,
        );

        #[optional]
        #[unsafe(method(authenticationSessionRequest:didCancelWithError:))]
        #[unsafe(method_family = none)]
        unsafe fn authenticationSessionRequest_didCancelWithError(
            &self,
            authentication_session_request: &ASWebAuthenticationSessionRequest,
            error: &NSError,
        );
    }
);

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

extern_conformance!(
    unsafe impl NSCoding for ASWebAuthenticationSessionRequest {}
);

extern_conformance!(
    unsafe impl NSCopying for ASWebAuthenticationSessionRequest {}
);

unsafe impl CopyingHelper for ASWebAuthenticationSessionRequest {
    type Result = Self;
}

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

extern_conformance!(
    unsafe impl NSSecureCoding for ASWebAuthenticationSessionRequest {}
);

impl ASWebAuthenticationSessionRequest {
    extern_methods!(
        #[unsafe(method(UUID))]
        #[unsafe(method_family = none)]
        pub unsafe fn UUID(&self) -> Retained<NSUUID>;

        #[unsafe(method(URL))]
        #[unsafe(method_family = none)]
        pub unsafe fn URL(&self) -> Retained<NSURL>;

        #[deprecated = "Use `callback` to match all callback types."]
        #[unsafe(method(callbackURLScheme))]
        #[unsafe(method_family = none)]
        pub unsafe fn callbackURLScheme(&self) -> Option<Retained<NSString>>;

        #[unsafe(method(shouldUseEphemeralSession))]
        #[unsafe(method_family = none)]
        pub unsafe fn shouldUseEphemeralSession(&self) -> bool;

        #[unsafe(method(delegate))]
        #[unsafe(method_family = none)]
        pub unsafe fn delegate(
            &self,
        ) -> Option<Retained<ProtocolObject<dyn ASWebAuthenticationSessionRequestDelegate>>>;

        /// Setter for [`delegate`][Self::delegate].
        ///
        /// This is a [weak property][objc2::topics::weak_property].
        #[unsafe(method(setDelegate:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setDelegate(
            &self,
            delegate: Option<&ProtocolObject<dyn ASWebAuthenticationSessionRequestDelegate>>,
        );

        /// Additional headers to be sent when loading the initial URL.
        /// These should _only_ apply to the initial page, and should not overwrite any headers normally sent by the browser.
        /// Add `AdditionalHeaderFieldsAreSupported: true` to `ASWebAuthenticationSessionWebBrowserSupportCapabilities` in your browser's Info.plist file to indicate support for this.
        #[unsafe(method(additionalHeaderFields))]
        #[unsafe(method_family = none)]
        pub unsafe fn additionalHeaderFields(
            &self,
        ) -> Option<Retained<NSDictionary<NSString, NSString>>>;

        #[cfg(feature = "ASWebAuthenticationSessionCallback")]
        /// The callback to listen for to complete this request.
        /// Check all main-frame navigations loaded during the request with this callback. It is used to handle all callback types, including custom schemes and HTTPS navigations.
        /// When a match is found, invoke `-completeWithCallbackURL:` with that URL.
        /// Add `CallbackURLMatchingIsSupported: true` to `ASWebAuthenticationSessionWebBrowserSupportCapabilities` in your browser's Info.plist file to indicate support for this.
        #[unsafe(method(callback))]
        #[unsafe(method_family = none)]
        pub unsafe fn callback(&self) -> Option<Retained<ASWebAuthenticationSessionCallback>>;

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

        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(cancelWithError:))]
        #[unsafe(method_family = none)]
        pub unsafe fn cancelWithError(&self, error: &NSError);

        #[unsafe(method(completeWithCallbackURL:))]
        #[unsafe(method_family = none)]
        pub unsafe fn completeWithCallbackURL(&self, url: &NSURL);
    );
}