objc2_accessory_setup_kit/generated/
ASAccessorySession.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5#[cfg(feature = "dispatch2")]
6use dispatch2::*;
7use objc2::__framework_prelude::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12extern_class!(
13    /// Manages accessories.
14    ///
15    /// See also [Apple's documentation](https://developer.apple.com/documentation/accessorysetupkit/asaccessorysession?language=objc)
16    #[unsafe(super(NSObject))]
17    #[derive(Debug, PartialEq, Eq, Hash)]
18    pub struct ASAccessorySession;
19);
20
21unsafe impl Send for ASAccessorySession {}
22
23unsafe impl Sync for ASAccessorySession {}
24
25extern_conformance!(
26    unsafe impl NSObjectProtocol for ASAccessorySession {}
27);
28
29impl ASAccessorySession {
30    extern_methods!(
31        #[cfg(feature = "ASAccessory")]
32        /// An array of previously-selected accessories for this application.
33        ///
34        /// To monitor for changes in this list, use your event handler to watch for the events ``ASAccessoryEventType/accessoryAdded``, ``ASAccessoryEventType/accessoryChanged``, and ``ASAccessoryEventType/accessoryRemoved``.
35        ///
36        /// This property is not atomic.
37        ///
38        /// # Safety
39        ///
40        /// This might not be thread-safe.
41        #[unsafe(method(accessories))]
42        #[unsafe(method_family = none)]
43        pub unsafe fn accessories(&self) -> Retained<NSArray<ASAccessory>>;
44
45        #[cfg(feature = "ASPickerDisplaySettings")]
46        /// Settings that affect the display of the accessory picker.
47        ///
48        /// Use this property to configure settings like the picker timeout.
49        ///
50        /// This property is not atomic.
51        ///
52        /// # Safety
53        ///
54        /// This might not be thread-safe.
55        #[unsafe(method(pickerDisplaySettings))]
56        #[unsafe(method_family = none)]
57        pub unsafe fn pickerDisplaySettings(&self) -> Option<Retained<ASPickerDisplaySettings>>;
58
59        #[cfg(feature = "ASPickerDisplaySettings")]
60        /// Setter for [`pickerDisplaySettings`][Self::pickerDisplaySettings].
61        ///
62        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
63        ///
64        /// # Safety
65        ///
66        /// This might not be thread-safe.
67        #[unsafe(method(setPickerDisplaySettings:))]
68        #[unsafe(method_family = none)]
69        pub unsafe fn setPickerDisplaySettings(
70            &self,
71            picker_display_settings: Option<&ASPickerDisplaySettings>,
72        );
73
74        #[cfg(all(
75            feature = "ASAccessoryEvent",
76            feature = "block2",
77            feature = "dispatch2"
78        ))]
79        /// Activate the session and start delivering events to an event handler.
80        /// - Parameters:
81        /// - queue: The dispatch the session uses to deliver events to `eventHandler`.
82        /// - eventHandler: A closure or block that receives events generated by the session. Each callback to the event handler provides an ``ASAccessoryEvent`` as a parameter, and expects no return value.
83        ///
84        /// # Safety
85        ///
86        /// `queue` possibly has additional threading requirements.
87        #[unsafe(method(activateWithQueue:eventHandler:))]
88        #[unsafe(method_family = none)]
89        pub unsafe fn activateWithQueue_eventHandler(
90            &self,
91            queue: &DispatchQueue,
92            event_handler: &block2::DynBlock<dyn Fn(NonNull<ASAccessoryEvent>)>,
93        );
94
95        /// Invalidate the session by stopping any operations.
96        ///
97        /// This call breaks any retain cycles. The session is unusable after calling `invalidate`.
98        #[unsafe(method(invalidate))]
99        #[unsafe(method_family = none)]
100        pub unsafe fn invalidate(&self);
101
102        #[cfg(feature = "block2")]
103        /// Present a picker that shows accessories managed by a Device Discovery Extension in your app.
104        ///
105        /// Use this method when your app includes a
106        /// <doc
107        /// ://com.apple.documentation/documentation/devicediscoveryextension> for its supported accessories. If your app doesn't use DDE, call ``showPickerForDisplayItems:completionHandler:`` with an array of ``ASPickerDisplayItem-c.class`` instances instead.
108        ///
109        /// The session's event handler receives events when this picker displays and dismisses, as well as when the person using the app picks an accessory.
110        ///
111        /// - Parameters:
112        /// - completionHandler: A block or closure that the picker calls when it completes the operation. The completion handler receives an
113        /// <doc
114        /// ://com.apple.documentation/documentation/Foundation/NSError> instance if the picker encounters an error.
115        #[unsafe(method(showPickerWithCompletionHandler:))]
116        #[unsafe(method_family = none)]
117        pub unsafe fn showPickerWithCompletionHandler(
118            &self,
119            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
120        );
121
122        #[cfg(all(feature = "ASPickerDisplayItem", feature = "block2"))]
123        /// Present a picker that shows discovered accessories matching an array of display items.
124        ///
125        /// The session's event handler receives events when this picker displays and dismisses, as well as when the person using the app picks an accessory.
126        ///
127        /// To migrate previously-configured accessories to AccessorySetupKit, add instances of ``ASMigrationDisplayItem`` to the `displayItems` array.
128        /// - Parameters:
129        /// - displayItems: An array of ``ASPickerDisplayItem`` instances describing accessories your app can set up. The picker displays only discovered accessories that match the properties of items in this array.
130        /// - completionHandler: A block or closure that the picker calls when it completes the operation. The completion handler receives an
131        /// <doc
132        /// ://com.apple.documentation/documentation/Foundation/NSError> instance if the picker encounters an error.
133        #[unsafe(method(showPickerForDisplayItems:completionHandler:))]
134        #[unsafe(method_family = none)]
135        pub unsafe fn showPickerForDisplayItems_completionHandler(
136            &self,
137            display_items: &NSArray<ASPickerDisplayItem>,
138            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
139        );
140
141        #[cfg(all(
142            feature = "ASAccessory",
143            feature = "ASAccessorySettings",
144            feature = "block2"
145        ))]
146        /// Finish authorization of a partially-setup accessory.
147        ///
148        /// Use this method in scenarios where an accessory has multiple wireless interfaces. For example, when an accessory has both Bluetooth and Wi-Fi, and your descriptor may only provides an SSID prefix. In this case, the Bluetooth interface onboards first and your app needs to then finish authorization with the full SSID.
149        #[unsafe(method(finishAuthorization:settings:completionHandler:))]
150        #[unsafe(method_family = none)]
151        pub unsafe fn finishAuthorization_settings_completionHandler(
152            &self,
153            accessory: &ASAccessory,
154            settings: &ASAccessorySettings,
155            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
156        );
157
158        #[cfg(all(feature = "ASAccessory", feature = "block2"))]
159        /// End authorization of a partially-configured accessory as a failure.
160        #[unsafe(method(failAuthorization:completionHandler:))]
161        #[unsafe(method_family = none)]
162        pub unsafe fn failAuthorization_completionHandler(
163            &self,
164            accessory: &ASAccessory,
165            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
166        );
167
168        #[cfg(all(feature = "ASAccessory", feature = "block2"))]
169        /// Removes an accessory.
170        ///
171        /// - Parameters:
172        /// - accessory: The accessory to remove.
173        /// - completionHandler: A block or closure that executes after the remove operation completes. The completion handler receives an
174        /// <doc
175        /// ://com.apple.documentation/documentation/Foundation/NSError> instance if the remove operation encounters an error.
176        #[unsafe(method(removeAccessory:completionHandler:))]
177        #[unsafe(method_family = none)]
178        pub unsafe fn removeAccessory_completionHandler(
179            &self,
180            accessory: &ASAccessory,
181            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
182        );
183
184        #[cfg(all(feature = "ASAccessory", feature = "block2"))]
185        /// Displays a view to rename an accessory.
186        ///
187        /// To rename a Wi-Fi SSID with this method, use the option ``ASAccessory/RenameOptions/ssid``.
188        ///
189        /// - Parameters:
190        /// - accessory: The accessory to rename.
191        /// - renameOptions: Options that affect the behavior of the rename operation.
192        /// - completionHandler: A block or closure that executes after the rename operation completes. The completion handler receives an
193        /// <doc
194        /// ://com.apple.documentation/documentation/Foundation/NSError> instance if the rename operation encounters an error.
195        #[unsafe(method(renameAccessory:options:completionHandler:))]
196        #[unsafe(method_family = none)]
197        pub unsafe fn renameAccessory_options_completionHandler(
198            &self,
199            accessory: &ASAccessory,
200            rename_options: ASAccessoryRenameOptions,
201            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
202        );
203
204        #[cfg(all(
205            feature = "ASAccessory",
206            feature = "ASDiscoveryDescriptor",
207            feature = "block2"
208        ))]
209        /// Displays a view to upgrade an accessory with additional technology permissions.
210        ///
211        /// Call this method to upgrade previously-added SSID-based accessories to use WiFi Aware.
212        ///
213        /// - Parameters:
214        /// - accessory: The accessory to update.
215        /// - descriptor: An updated descriptor that the picker uses to add new technology authorization for the provided accessory.
216        /// - completionHandler: A block or closure that executes after the picker is shown. The completion handler receives an
217        /// <doc
218        /// ://com.apple.documentation/documentation/Foundation/NSError> instance if the upgrade operation encounters an error. In Swift, you can omit the completion handler by calling the method asynchronously and catching any error thrown by the method.
219        #[unsafe(method(updateAuthorization:descriptor:completionHandler:))]
220        #[unsafe(method_family = none)]
221        pub unsafe fn updateAuthorization_descriptor_completionHandler(
222            &self,
223            accessory: &ASAccessory,
224            descriptor: &ASDiscoveryDescriptor,
225            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
226        );
227    );
228}
229
230/// Methods declared on superclass `NSObject`.
231impl ASAccessorySession {
232    extern_methods!(
233        #[unsafe(method(init))]
234        #[unsafe(method_family = init)]
235        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
236
237        #[unsafe(method(new))]
238        #[unsafe(method_family = new)]
239        pub unsafe fn new() -> Retained<Self>;
240    );
241}