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/// Tell the authorization controller that it should prefer credentials that are immediately available on the local device.
71        #[doc(alias = "ASAuthorizationControllerRequestOptionPreferImmediatelyAvailableCredentials")]
72        const PreferImmediatelyAvailableCredentials = 1<<0;
73    }
74}
75
76unsafe impl Encode for ASAuthorizationControllerRequestOptions {
77    const ENCODING: Encoding = NSUInteger::ENCODING;
78}
79
80unsafe impl RefEncode for ASAuthorizationControllerRequestOptions {
81    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
82}
83
84extern_class!(
85    /// [Apple's documentation](https://developer.apple.com/documentation/authenticationservices/asauthorizationcontroller?language=objc)
86    #[unsafe(super(NSObject))]
87    #[derive(Debug, PartialEq, Eq, Hash)]
88    pub struct ASAuthorizationController;
89);
90
91extern_conformance!(
92    unsafe impl NSObjectProtocol for ASAuthorizationController {}
93);
94
95impl ASAuthorizationController {
96    extern_methods!(
97        #[cfg(feature = "ASAuthorizationRequest")]
98        /// Authorization requests that are being serviced by this controller
99        #[unsafe(method(authorizationRequests))]
100        #[unsafe(method_family = none)]
101        pub unsafe fn authorizationRequests(&self) -> Retained<NSArray<ASAuthorizationRequest>>;
102
103        /// This delegate will be invoked upon completion of the authorization indicating success or failure.
104        /// Delegate is required to receive the results of authorization.
105        #[unsafe(method(delegate))]
106        #[unsafe(method_family = none)]
107        pub unsafe fn delegate(
108            &self,
109            mtm: MainThreadMarker,
110        ) -> Option<Retained<ProtocolObject<dyn ASAuthorizationControllerDelegate>>>;
111
112        /// This is a [weak property][objc2::topics::weak_property].
113        /// Setter for [`delegate`][Self::delegate].
114        #[unsafe(method(setDelegate:))]
115        #[unsafe(method_family = none)]
116        pub unsafe fn setDelegate(
117            &self,
118            delegate: Option<&ProtocolObject<dyn ASAuthorizationControllerDelegate>>,
119        );
120
121        /// This delegate will be invoked upon needing a presentation context to display authorization UI.
122        #[unsafe(method(presentationContextProvider))]
123        #[unsafe(method_family = none)]
124        pub unsafe fn presentationContextProvider(
125            &self,
126            mtm: MainThreadMarker,
127        ) -> Option<
128            Retained<ProtocolObject<dyn ASAuthorizationControllerPresentationContextProviding>>,
129        >;
130
131        /// This is a [weak property][objc2::topics::weak_property].
132        /// Setter for [`presentationContextProvider`][Self::presentationContextProvider].
133        #[unsafe(method(setPresentationContextProvider:))]
134        #[unsafe(method_family = none)]
135        pub unsafe fn setPresentationContextProvider(
136            &self,
137            presentation_context_provider: Option<
138                &ProtocolObject<dyn ASAuthorizationControllerPresentationContextProviding>,
139            >,
140        );
141
142        #[cfg(feature = "ASAuthorizationCustomMethod")]
143        /// A list of custom authorization methods that may be displayed in the authorization UI.
144        ///
145        /// If the user selects one of these methods, instead of attempting to secure an authorization for the requests, the
146        /// controller will call authorizationController:didCompleteWithCustomMethod: with the selected method, allowing
147        /// the client to perform the requested authorization.
148        #[unsafe(method(customAuthorizationMethods))]
149        #[unsafe(method_family = none)]
150        pub unsafe fn customAuthorizationMethods(
151            &self,
152        ) -> Retained<NSArray<ASAuthorizationCustomMethod>>;
153
154        #[cfg(feature = "ASAuthorizationCustomMethod")]
155        /// Setter for [`customAuthorizationMethods`][Self::customAuthorizationMethods].
156        #[unsafe(method(setCustomAuthorizationMethods:))]
157        #[unsafe(method_family = none)]
158        pub unsafe fn setCustomAuthorizationMethods(
159            &self,
160            custom_authorization_methods: &NSArray<ASAuthorizationCustomMethod>,
161        );
162
163        #[cfg(feature = "ASAuthorizationRequest")]
164        /// Initialize the controller with authorization requests.
165        ///
166        ///
167        /// Parameter `authorizationRequests`: At least one request should be provided. Requests of same type maybe honored in first in first out order
168        #[unsafe(method(initWithAuthorizationRequests:))]
169        #[unsafe(method_family = init)]
170        pub unsafe fn initWithAuthorizationRequests(
171            this: Allocated<Self>,
172            authorization_requests: &NSArray<ASAuthorizationRequest>,
173        ) -> Retained<Self>;
174
175        /// Initiate the authorization flows. Upon completion, the delegate will be called with either success or failure.
176        /// Certain authorization flows may require a presentation context. The
177        /// `presentationContextProvider`will be called
178        /// to provide it.
179        ///
180        /// The instance will remain retained until the flow is either completed or canceled, and the delegate callback is made.
181        #[unsafe(method(performRequests))]
182        #[unsafe(method_family = none)]
183        pub unsafe fn performRequests(&self);
184
185        /// Initiate the authorization flows for requests that support AutoFill presentation. UI will be shown when
186        /// focusing a text field with the appropriate text content type. Upon completion, the delegate will be called with either success
187        /// or failure.
188        ///
189        /// The instance will remain retained until the flow is either completed or canceled, and the delegate callback is made.
190        #[unsafe(method(performAutoFillAssistedRequests))]
191        #[unsafe(method_family = none)]
192        pub unsafe fn performAutoFillAssistedRequests(&self);
193
194        /// Initiate the authorization flows. Upon completion, the delegate will be called with either success or failure.
195        /// Certain authorization flows may require a presentation context. The
196        /// `presentationContextProvider`will be called
197        /// to provide it.
198        ///
199        /// Calling this method with no options is the same as calling
200        /// `performRequests.`The instance will remain retained until
201        /// the flow is either completed or canceled, and the delegate callback is made.
202        #[unsafe(method(performRequestsWithOptions:))]
203        #[unsafe(method_family = none)]
204        pub unsafe fn performRequestsWithOptions(
205            &self,
206            options: ASAuthorizationControllerRequestOptions,
207        );
208
209        /// Cancel the running authorization flows, if there are any. If a flow is canceled, the delegate callback will
210        /// be made indicating the cancel.
211        #[unsafe(method(cancel))]
212        #[unsafe(method_family = none)]
213        pub unsafe fn cancel(&self);
214
215        #[unsafe(method(new))]
216        #[unsafe(method_family = new)]
217        pub unsafe fn new() -> Retained<Self>;
218
219        #[unsafe(method(init))]
220        #[unsafe(method_family = init)]
221        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
222    );
223}