objc2_security_interface/generated/
SFAuthorizationView.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_app_kit::*;
7use objc2_foundation::*;
8#[cfg(feature = "objc2-security")]
9use objc2_security::*;
10#[cfg(feature = "objc2-security-foundation")]
11use objc2_security_foundation::*;
12
13use crate::*;
14
15/// Defines the current state of the authorization view.
16///
17/// See also [Apple's documentation](https://developer.apple.com/documentation/securityinterface/sfauthorizationviewstate?language=objc)
18#[repr(transparent)]
19#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
20pub struct SFAuthorizationViewState(pub c_uint);
21impl SFAuthorizationViewState {
22    #[doc(alias = "SFAuthorizationStartupState")]
23    pub const StartupState: Self = Self(0);
24    #[doc(alias = "SFAuthorizationViewLockedState")]
25    pub const ViewLockedState: Self = Self(1);
26    #[doc(alias = "SFAuthorizationViewInProgressState")]
27    pub const ViewInProgressState: Self = Self(2);
28    #[doc(alias = "SFAuthorizationViewUnlockedState")]
29    pub const ViewUnlockedState: Self = Self(3);
30}
31
32unsafe impl Encode for SFAuthorizationViewState {
33    const ENCODING: Encoding = c_uint::ENCODING;
34}
35
36unsafe impl RefEncode for SFAuthorizationViewState {
37    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
38}
39
40extern_class!(
41    /// [Apple's documentation](https://developer.apple.com/documentation/securityinterface/sfauthorizationview?language=objc)
42    #[unsafe(super(NSView, NSResponder, NSObject))]
43    #[derive(Debug, PartialEq, Eq, Hash)]
44    pub struct SFAuthorizationView;
45);
46
47extern_conformance!(
48    unsafe impl NSAccessibility for SFAuthorizationView {}
49);
50
51extern_conformance!(
52    unsafe impl NSAccessibilityElementProtocol for SFAuthorizationView {}
53);
54
55extern_conformance!(
56    unsafe impl NSAnimatablePropertyContainer for SFAuthorizationView {}
57);
58
59extern_conformance!(
60    unsafe impl NSAppearanceCustomization for SFAuthorizationView {}
61);
62
63extern_conformance!(
64    unsafe impl NSCoding for SFAuthorizationView {}
65);
66
67extern_conformance!(
68    unsafe impl NSDraggingDestination for SFAuthorizationView {}
69);
70
71extern_conformance!(
72    unsafe impl NSObjectProtocol for SFAuthorizationView {}
73);
74
75extern_conformance!(
76    unsafe impl NSUserInterfaceItemIdentification for SFAuthorizationView {}
77);
78
79impl SFAuthorizationView {
80    extern_methods!(
81        #[cfg(feature = "objc2-security")]
82        /// A convenience method to specify an authorization rights set containing a single item with the name set to the specified string.
83        ///
84        /// Parameter `authorizationString`: Authorization string.
85        ///
86        /// # Safety
87        ///
88        /// `authorization_string` must be a valid pointer.
89        #[unsafe(method(setString:))]
90        #[unsafe(method_family = none)]
91        pub unsafe fn setString(&self, authorization_string: AuthorizationString);
92
93        #[cfg(feature = "objc2-security")]
94        /// Sets the authorization rights for this view.
95        ///
96        /// Parameter `authorizationRights`: Authorization rights.
97        ///
98        /// # Safety
99        ///
100        /// `authorization_rights` must be a valid pointer.
101        #[unsafe(method(setAuthorizationRights:))]
102        #[unsafe(method_family = none)]
103        pub unsafe fn setAuthorizationRights(
104            &self,
105            authorization_rights: *const AuthorizationRights,
106        );
107
108        #[cfg(feature = "objc2-security")]
109        /// Returns the authorization rights for this view.
110        #[unsafe(method(authorizationRights))]
111        #[unsafe(method_family = none)]
112        pub unsafe fn authorizationRights(&self) -> *mut AuthorizationRights;
113
114        #[cfg(feature = "objc2-security-foundation")]
115        /// Returns the authorization object associated with this view.
116        #[unsafe(method(authorization))]
117        #[unsafe(method_family = none)]
118        pub unsafe fn authorization(&self) -> Option<Retained<SFAuthorization>>;
119
120        /// This method is called when the state of the authorization object has changed.
121        ///
122        /// Parameter `inSender`: The action that is marked for updateStatus.
123        ///
124        /// # Safety
125        ///
126        /// - `in_sender` should be of the correct type.
127        /// - `in_sender` might not allow `None`.
128        #[unsafe(method(updateStatus:))]
129        #[unsafe(method_family = none)]
130        pub unsafe fn updateStatus(&self, in_sender: Option<&AnyObject>) -> bool;
131
132        #[unsafe(method(setAutoupdate:))]
133        #[unsafe(method_family = none)]
134        pub unsafe fn setAutoupdate(&self, autoupdate: bool);
135
136        #[unsafe(method(setAutoupdate:interval:))]
137        #[unsafe(method_family = none)]
138        pub unsafe fn setAutoupdate_interval(&self, autoupdate: bool, interval: NSTimeInterval);
139
140        /// Returns the current state of the authorization view.
141        #[unsafe(method(authorizationState))]
142        #[unsafe(method_family = none)]
143        pub unsafe fn authorizationState(&self) -> SFAuthorizationViewState;
144
145        /// Sets the current state of the authorization view.
146        ///
147        /// Parameter `enabled`: Enable flag.
148        #[unsafe(method(setEnabled:))]
149        #[unsafe(method_family = none)]
150        pub unsafe fn setEnabled(&self, enabled: bool);
151
152        /// Indicates if the authorization view is enabled or disabled.
153        #[unsafe(method(isEnabled))]
154        #[unsafe(method_family = none)]
155        pub unsafe fn isEnabled(&self) -> bool;
156
157        #[cfg(feature = "objc2-security")]
158        /// Sets the current authorization flags for the view.
159        ///
160        /// Parameter `flags`: Authorization flags.
161        #[unsafe(method(setFlags:))]
162        #[unsafe(method_family = none)]
163        pub unsafe fn setFlags(&self, flags: AuthorizationFlags);
164
165        /// Sets the delegate for this authorization view. If you want to hear state changes (for example, the user clicked the button), set your delegate and implement the delegate methods mentioned for SFAuthorizationViewDelegate
166        ///
167        /// Parameter `delegate`: The client's delegate object.
168        ///
169        /// # Safety
170        ///
171        /// - `delegate` should be of the correct type.
172        /// - `delegate` might not allow `None`.
173        #[unsafe(method(setDelegate:))]
174        #[unsafe(method_family = none)]
175        pub unsafe fn setDelegate(&self, delegate: Option<&AnyObject>);
176
177        #[unsafe(method(delegate))]
178        #[unsafe(method_family = none)]
179        pub unsafe fn delegate(&self) -> Option<Retained<AnyObject>>;
180
181        /// # Safety
182        ///
183        /// - `in_sender` should be of the correct type.
184        /// - `in_sender` might not allow `None`.
185        #[unsafe(method(authorize:))]
186        #[unsafe(method_family = none)]
187        pub unsafe fn authorize(&self, in_sender: Option<&AnyObject>) -> bool;
188
189        /// # Safety
190        ///
191        /// - `in_sender` should be of the correct type.
192        /// - `in_sender` might not allow `None`.
193        #[unsafe(method(deauthorize:))]
194        #[unsafe(method_family = none)]
195        pub unsafe fn deauthorize(&self, in_sender: Option<&AnyObject>) -> bool;
196    );
197}
198
199/// Methods declared on superclass `NSView`.
200impl SFAuthorizationView {
201    extern_methods!(
202        #[unsafe(method(initWithFrame:))]
203        #[unsafe(method_family = init)]
204        pub unsafe fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;
205
206        /// # Safety
207        ///
208        /// `coder` possibly has further requirements.
209        #[unsafe(method(initWithCoder:))]
210        #[unsafe(method_family = init)]
211        pub unsafe fn initWithCoder(
212            this: Allocated<Self>,
213            coder: &NSCoder,
214        ) -> Option<Retained<Self>>;
215    );
216}
217
218/// Methods declared on superclass `NSResponder`.
219impl SFAuthorizationView {
220    extern_methods!(
221        #[unsafe(method(init))]
222        #[unsafe(method_family = init)]
223        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
224    );
225}
226
227/// Methods declared on superclass `NSObject`.
228impl SFAuthorizationView {
229    extern_methods!(
230        #[unsafe(method(new))]
231        #[unsafe(method_family = new)]
232        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
233    );
234}
235
236mod private_NSObjectSFAuthorizationViewDelegate {
237    pub trait Sealed {}
238}
239
240/// Category "SFAuthorizationViewDelegate" on [`NSObject`].
241///
242/// Optionally implement these delegate methods to obtain the state of the authorization object.
243#[doc(alias = "SFAuthorizationViewDelegate")]
244pub unsafe trait NSObjectSFAuthorizationViewDelegate:
245    ClassType + Sized + private_NSObjectSFAuthorizationViewDelegate::Sealed
246{
247    extern_methods!(
248        /// Parameter `view`:
249        ///
250        /// # Safety
251        ///
252        /// `view` might not allow `None`.
253        #[unsafe(method(authorizationViewDidAuthorize:))]
254        #[unsafe(method_family = none)]
255        unsafe fn authorizationViewDidAuthorize(&self, view: Option<&SFAuthorizationView>);
256
257        /// Parameter `view`:
258        ///
259        /// # Safety
260        ///
261        /// `view` might not allow `None`.
262        #[unsafe(method(authorizationViewDidDeauthorize:))]
263        #[unsafe(method_family = none)]
264        unsafe fn authorizationViewDidDeauthorize(&self, view: Option<&SFAuthorizationView>);
265
266        /// Parameter `view`:
267        ///
268        /// # Safety
269        ///
270        /// `view` might not allow `None`.
271        #[unsafe(method(authorizationViewShouldDeauthorize:))]
272        #[unsafe(method_family = none)]
273        unsafe fn authorizationViewShouldDeauthorize(
274            &self,
275            view: Option<&SFAuthorizationView>,
276        ) -> bool;
277
278        /// Parameter `view`:
279        ///
280        /// # Safety
281        ///
282        /// `view` might not allow `None`.
283        #[unsafe(method(authorizationViewCreatedAuthorization:))]
284        #[unsafe(method_family = none)]
285        unsafe fn authorizationViewCreatedAuthorization(&self, view: Option<&SFAuthorizationView>);
286
287        /// Parameter `view`:
288        ///
289        /// # Safety
290        ///
291        /// `view` might not allow `None`.
292        #[unsafe(method(authorizationViewReleasedAuthorization:))]
293        #[unsafe(method_family = none)]
294        unsafe fn authorizationViewReleasedAuthorization(&self, view: Option<&SFAuthorizationView>);
295
296        /// Parameter `view`:
297        ///
298        /// # Safety
299        ///
300        /// `view` might not allow `None`.
301        #[unsafe(method(authorizationViewDidHide:))]
302        #[unsafe(method_family = none)]
303        unsafe fn authorizationViewDidHide(&self, view: Option<&SFAuthorizationView>);
304    );
305}
306
307impl private_NSObjectSFAuthorizationViewDelegate::Sealed for NSObject {}
308unsafe impl NSObjectSFAuthorizationViewDelegate for NSObject {}