objc2_authentication_services/generated/
ASAuthorizationController.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::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10extern_protocol!(
11    /// [Apple's documentation](https://developer.apple.com/documentation/authenticationservices/asauthorizationcontrollerdelegate?language=objc)
12    pub unsafe trait ASAuthorizationControllerDelegate:
13        NSObjectProtocol + MainThreadOnly
14    {
15        #[cfg(feature = "ASAuthorization")]
16        #[optional]
17        #[unsafe(method(authorizationController:didCompleteWithAuthorization:))]
18        #[unsafe(method_family = none)]
19        unsafe fn authorizationController_didCompleteWithAuthorization(
20            &self,
21            controller: &ASAuthorizationController,
22            authorization: &ASAuthorization,
23        );
24
25        #[optional]
26        #[unsafe(method(authorizationController:didCompleteWithError:))]
27        #[unsafe(method_family = none)]
28        unsafe fn authorizationController_didCompleteWithError(
29            &self,
30            controller: &ASAuthorizationController,
31            error: &NSError,
32        );
33
34        #[cfg(feature = "ASAuthorizationCustomMethod")]
35        #[optional]
36        #[unsafe(method(authorizationController:didCompleteWithCustomMethod:))]
37        #[unsafe(method_family = none)]
38        unsafe fn authorizationController_didCompleteWithCustomMethod(
39            &self,
40            controller: &ASAuthorizationController,
41            method: &ASAuthorizationCustomMethod,
42        );
43    }
44);
45
46extern_protocol!(
47    /// [Apple's documentation](https://developer.apple.com/documentation/authenticationservices/asauthorizationcontrollerpresentationcontextproviding?language=objc)
48    pub unsafe trait ASAuthorizationControllerPresentationContextProviding:
49        NSObjectProtocol + MainThreadOnly
50    {
51        #[cfg(feature = "ASFoundation")]
52        #[cfg(target_os = "macos")]
53        /// Return a view anchor that is most appropriate for athorization UI to be presented over.  This view will be used as a hint if a credential provider requires user interaction.
54        #[unsafe(method(presentationAnchorForAuthorizationController:))]
55        #[unsafe(method_family = none)]
56        unsafe fn presentationAnchorForAuthorizationController(
57            &self,
58            controller: &ASAuthorizationController,
59        ) -> Retained<ASPresentationAnchor>;
60    }
61);
62
63/// [Apple's documentation](https://developer.apple.com/documentation/authenticationservices/asauthorizationcontrollerrequestoptions?language=objc)
64// NS_OPTIONS
65#[repr(transparent)]
66#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
67pub struct ASAuthorizationControllerRequestOptions(pub NSUInteger);
68bitflags::bitflags! {
69    impl ASAuthorizationControllerRequestOptions: NSUInteger {
70/// When used for sign-in requests, tell the authorization controller that it should only be presented if there are credentials immediately available on the local device.
71/// When used for registration requests, tell the authorization controller that it should only be presented if the local device is currently set up to fulfill at least one of the request types.
72        #[doc(alias = "ASAuthorizationControllerRequestOptionPreferImmediatelyAvailableCredentials")]
73        const PreferImmediatelyAvailableCredentials = 1<<0;
74    }
75}
76
77unsafe impl Encode for ASAuthorizationControllerRequestOptions {
78    const ENCODING: Encoding = NSUInteger::ENCODING;
79}
80
81unsafe impl RefEncode for ASAuthorizationControllerRequestOptions {
82    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
83}
84
85extern_class!(
86    /// [Apple's documentation](https://developer.apple.com/documentation/authenticationservices/asauthorizationcontroller?language=objc)
87    #[unsafe(super(NSObject))]
88    #[derive(Debug, PartialEq, Eq, Hash)]
89    pub struct ASAuthorizationController;
90);
91
92extern_conformance!(
93    unsafe impl NSObjectProtocol for ASAuthorizationController {}
94);
95
96impl ASAuthorizationController {
97    extern_methods!(
98        #[cfg(feature = "ASAuthorizationRequest")]
99        /// Authorization requests that are being serviced by this controller
100        #[unsafe(method(authorizationRequests))]
101        #[unsafe(method_family = none)]
102        pub unsafe fn authorizationRequests(&self) -> Retained<NSArray<ASAuthorizationRequest>>;
103
104        /// This delegate will be invoked upon completion of the authorization indicating success or failure.
105        /// Delegate is required to receive the results of authorization.
106        #[unsafe(method(delegate))]
107        #[unsafe(method_family = none)]
108        pub unsafe fn delegate(
109            &self,
110            mtm: MainThreadMarker,
111        ) -> Option<Retained<ProtocolObject<dyn ASAuthorizationControllerDelegate>>>;
112
113        /// Setter for [`delegate`][Self::delegate].
114        ///
115        /// This is a [weak property][objc2::topics::weak_property].
116        #[unsafe(method(setDelegate:))]
117        #[unsafe(method_family = none)]
118        pub unsafe fn setDelegate(
119            &self,
120            delegate: Option<&ProtocolObject<dyn ASAuthorizationControllerDelegate>>,
121        );
122
123        /// This delegate will be invoked upon needing a presentation context to display authorization UI.
124        #[unsafe(method(presentationContextProvider))]
125        #[unsafe(method_family = none)]
126        pub unsafe fn presentationContextProvider(
127            &self,
128            mtm: MainThreadMarker,
129        ) -> Option<
130            Retained<ProtocolObject<dyn ASAuthorizationControllerPresentationContextProviding>>,
131        >;
132
133        /// Setter for [`presentationContextProvider`][Self::presentationContextProvider].
134        ///
135        /// This is a [weak property][objc2::topics::weak_property].
136        #[unsafe(method(setPresentationContextProvider:))]
137        #[unsafe(method_family = none)]
138        pub unsafe fn setPresentationContextProvider(
139            &self,
140            presentation_context_provider: Option<
141                &ProtocolObject<dyn ASAuthorizationControllerPresentationContextProviding>,
142            >,
143        );
144
145        #[cfg(feature = "ASAuthorizationCustomMethod")]
146        /// A list of custom authorization methods that may be displayed in the authorization UI.
147        ///
148        /// If the user selects one of these methods, instead of attempting to secure an authorization for the requests, the
149        /// controller will call authorizationController:didCompleteWithCustomMethod: with the selected method, allowing
150        /// the client to perform the requested authorization.
151        #[unsafe(method(customAuthorizationMethods))]
152        #[unsafe(method_family = none)]
153        pub unsafe fn customAuthorizationMethods(
154            &self,
155        ) -> Retained<NSArray<ASAuthorizationCustomMethod>>;
156
157        #[cfg(feature = "ASAuthorizationCustomMethod")]
158        /// Setter for [`customAuthorizationMethods`][Self::customAuthorizationMethods].
159        ///
160        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
161        #[unsafe(method(setCustomAuthorizationMethods:))]
162        #[unsafe(method_family = none)]
163        pub unsafe fn setCustomAuthorizationMethods(
164            &self,
165            custom_authorization_methods: &NSArray<ASAuthorizationCustomMethod>,
166        );
167
168        #[cfg(feature = "ASAuthorizationRequest")]
169        /// Initialize the controller with authorization requests.
170        ///
171        ///
172        /// Parameter `authorizationRequests`: At least one request should be provided. Requests of same type maybe honored in first in first out order
173        #[unsafe(method(initWithAuthorizationRequests:))]
174        #[unsafe(method_family = init)]
175        pub unsafe fn initWithAuthorizationRequests(
176            this: Allocated<Self>,
177            authorization_requests: &NSArray<ASAuthorizationRequest>,
178        ) -> Retained<Self>;
179
180        /// Initiate the authorization flows. Upon completion, the delegate will be called with either success or failure.
181        /// Certain authorization flows may require a presentation context. The
182        /// `presentationContextProvider`will be called
183        /// to provide it.
184        ///
185        /// The instance will remain retained until the flow is either completed or canceled, and the delegate callback is made.
186        #[unsafe(method(performRequests))]
187        #[unsafe(method_family = none)]
188        pub unsafe fn performRequests(&self);
189
190        /// Initiate the authorization flows for requests that support AutoFill presentation. UI will be shown when
191        /// focusing a text field with the appropriate text content type. Upon completion, the delegate will be called with either success
192        /// or failure.
193        ///
194        /// The instance will remain retained until the flow is either completed or canceled, and the delegate callback is made.
195        #[unsafe(method(performAutoFillAssistedRequests))]
196        #[unsafe(method_family = none)]
197        pub unsafe fn performAutoFillAssistedRequests(&self);
198
199        /// Initiate the authorization flows. Upon completion, the delegate will be called with either success or failure.
200        /// Certain authorization flows may require a presentation context. The
201        /// `presentationContextProvider`will be called
202        /// to provide it.
203        ///
204        /// Calling this method with no options is the same as calling
205        /// `performRequests.`The instance will remain retained until
206        /// the flow is either completed or canceled, and the delegate callback is made.
207        #[unsafe(method(performRequestsWithOptions:))]
208        #[unsafe(method_family = none)]
209        pub unsafe fn performRequestsWithOptions(
210            &self,
211            options: ASAuthorizationControllerRequestOptions,
212        );
213
214        /// Cancel the running authorization flows, if there are any. If a flow is canceled, the delegate callback will
215        /// be made indicating the cancel.
216        #[unsafe(method(cancel))]
217        #[unsafe(method_family = none)]
218        pub unsafe fn cancel(&self);
219
220        #[unsafe(method(new))]
221        #[unsafe(method_family = new)]
222        pub unsafe fn new() -> Retained<Self>;
223
224        #[unsafe(method(init))]
225        #[unsafe(method_family = init)]
226        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
227    );
228}