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        #[unsafe(method(setString:))]
86        #[unsafe(method_family = none)]
87        pub unsafe fn setString(&self, authorization_string: AuthorizationString);
88
89        #[cfg(feature = "objc2-security")]
90        /// Sets the authorization rights for this view.
91        ///
92        /// Parameter `authorizationRights`: Authorization rights.
93        #[unsafe(method(setAuthorizationRights:))]
94        #[unsafe(method_family = none)]
95        pub unsafe fn setAuthorizationRights(
96            &self,
97            authorization_rights: *const AuthorizationRights,
98        );
99
100        #[cfg(feature = "objc2-security")]
101        /// Returns the authorization rights for this view.
102        #[unsafe(method(authorizationRights))]
103        #[unsafe(method_family = none)]
104        pub unsafe fn authorizationRights(&self) -> *mut AuthorizationRights;
105
106        #[cfg(feature = "objc2-security-foundation")]
107        /// Returns the authorization object associated with this view.
108        #[unsafe(method(authorization))]
109        #[unsafe(method_family = none)]
110        pub unsafe fn authorization(&self) -> Option<Retained<SFAuthorization>>;
111
112        /// This method is called when the state of the authorization object has changed.
113        ///
114        /// Parameter `inSender`: The action that is marked for updateStatus.
115        #[unsafe(method(updateStatus:))]
116        #[unsafe(method_family = none)]
117        pub unsafe fn updateStatus(&self, in_sender: Option<&AnyObject>) -> bool;
118
119        #[unsafe(method(setAutoupdate:))]
120        #[unsafe(method_family = none)]
121        pub unsafe fn setAutoupdate(&self, autoupdate: bool);
122
123        #[unsafe(method(setAutoupdate:interval:))]
124        #[unsafe(method_family = none)]
125        pub unsafe fn setAutoupdate_interval(&self, autoupdate: bool, interval: NSTimeInterval);
126
127        /// Returns the current state of the authorization view.
128        #[unsafe(method(authorizationState))]
129        #[unsafe(method_family = none)]
130        pub unsafe fn authorizationState(&self) -> SFAuthorizationViewState;
131
132        /// Sets the current state of the authorization view.
133        ///
134        /// Parameter `enabled`: Enable flag.
135        #[unsafe(method(setEnabled:))]
136        #[unsafe(method_family = none)]
137        pub unsafe fn setEnabled(&self, enabled: bool);
138
139        /// Indicates if the authorization view is enabled or disabled.
140        #[unsafe(method(isEnabled))]
141        #[unsafe(method_family = none)]
142        pub unsafe fn isEnabled(&self) -> bool;
143
144        #[cfg(feature = "objc2-security")]
145        /// Sets the current authorization flags for the view.
146        ///
147        /// Parameter `flags`: Authorization flags.
148        #[unsafe(method(setFlags:))]
149        #[unsafe(method_family = none)]
150        pub unsafe fn setFlags(&self, flags: AuthorizationFlags);
151
152        /// 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
153        ///
154        /// Parameter `delegate`: The client's delegate object.
155        #[unsafe(method(setDelegate:))]
156        #[unsafe(method_family = none)]
157        pub unsafe fn setDelegate(&self, delegate: Option<&AnyObject>);
158
159        #[unsafe(method(delegate))]
160        #[unsafe(method_family = none)]
161        pub unsafe fn delegate(&self) -> Option<Retained<AnyObject>>;
162
163        #[unsafe(method(authorize:))]
164        #[unsafe(method_family = none)]
165        pub unsafe fn authorize(&self, in_sender: Option<&AnyObject>) -> bool;
166
167        #[unsafe(method(deauthorize:))]
168        #[unsafe(method_family = none)]
169        pub unsafe fn deauthorize(&self, in_sender: Option<&AnyObject>) -> bool;
170    );
171}
172
173/// Methods declared on superclass `NSView`.
174impl SFAuthorizationView {
175    extern_methods!(
176        #[unsafe(method(initWithFrame:))]
177        #[unsafe(method_family = init)]
178        pub unsafe fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;
179
180        #[unsafe(method(initWithCoder:))]
181        #[unsafe(method_family = init)]
182        pub unsafe fn initWithCoder(
183            this: Allocated<Self>,
184            coder: &NSCoder,
185        ) -> Option<Retained<Self>>;
186    );
187}
188
189/// Methods declared on superclass `NSResponder`.
190impl SFAuthorizationView {
191    extern_methods!(
192        #[unsafe(method(init))]
193        #[unsafe(method_family = init)]
194        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
195    );
196}
197
198/// Methods declared on superclass `NSObject`.
199impl SFAuthorizationView {
200    extern_methods!(
201        #[unsafe(method(new))]
202        #[unsafe(method_family = new)]
203        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
204    );
205}
206
207mod private_NSObjectSFAuthorizationViewDelegate {
208    pub trait Sealed {}
209}
210
211/// Category "SFAuthorizationViewDelegate" on [`NSObject`].
212/// Optionally implement these delegate methods to obtain the state of the authorization object.
213#[doc(alias = "SFAuthorizationViewDelegate")]
214pub unsafe trait NSObjectSFAuthorizationViewDelegate:
215    ClassType + Sized + private_NSObjectSFAuthorizationViewDelegate::Sealed
216{
217    extern_methods!(
218        /// Parameter `view`:
219        #[unsafe(method(authorizationViewDidAuthorize:))]
220        #[unsafe(method_family = none)]
221        unsafe fn authorizationViewDidAuthorize(&self, view: Option<&SFAuthorizationView>);
222
223        /// Parameter `view`:
224        #[unsafe(method(authorizationViewDidDeauthorize:))]
225        #[unsafe(method_family = none)]
226        unsafe fn authorizationViewDidDeauthorize(&self, view: Option<&SFAuthorizationView>);
227
228        /// Parameter `view`:
229        #[unsafe(method(authorizationViewShouldDeauthorize:))]
230        #[unsafe(method_family = none)]
231        unsafe fn authorizationViewShouldDeauthorize(
232            &self,
233            view: Option<&SFAuthorizationView>,
234        ) -> bool;
235
236        /// Parameter `view`:
237        #[unsafe(method(authorizationViewCreatedAuthorization:))]
238        #[unsafe(method_family = none)]
239        unsafe fn authorizationViewCreatedAuthorization(&self, view: Option<&SFAuthorizationView>);
240
241        /// Parameter `view`:
242        #[unsafe(method(authorizationViewReleasedAuthorization:))]
243        #[unsafe(method_family = none)]
244        unsafe fn authorizationViewReleasedAuthorization(&self, view: Option<&SFAuthorizationView>);
245
246        /// Parameter `view`:
247        #[unsafe(method(authorizationViewDidHide:))]
248        #[unsafe(method_family = none)]
249        unsafe fn authorizationViewDidHide(&self, view: Option<&SFAuthorizationView>);
250    );
251}
252
253impl private_NSObjectSFAuthorizationViewDelegate::Sealed for NSObject {}
254unsafe impl NSObjectSFAuthorizationViewDelegate for NSObject {}