objc2_home_kit/generated/HMAccessoryBrowser.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_class!(
11 /// This class is used to discover new accessories in the home
12 /// that have never been paired with and therefore not part of the home.
13 ///
14 /// See also [Apple's documentation](https://developer.apple.com/documentation/homekit/hmaccessorybrowser?language=objc)
15 #[unsafe(super(NSObject))]
16 #[derive(Debug, PartialEq, Eq, Hash)]
17 pub struct HMAccessoryBrowser;
18);
19
20unsafe impl Send for HMAccessoryBrowser {}
21
22unsafe impl Sync for HMAccessoryBrowser {}
23
24extern_conformance!(
25 unsafe impl NSObjectProtocol for HMAccessoryBrowser {}
26);
27
28impl HMAccessoryBrowser {
29 extern_methods!(
30 #[unsafe(method(init))]
31 #[unsafe(method_family = init)]
32 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
33
34 /// Delegate that receives updates on the state of the accessories discovered.
35 ///
36 /// This property is not atomic.
37 ///
38 /// # Safety
39 ///
40 /// This might not be thread-safe.
41 #[unsafe(method(delegate))]
42 #[unsafe(method_family = none)]
43 pub unsafe fn delegate(
44 &self,
45 ) -> Option<Retained<ProtocolObject<dyn HMAccessoryBrowserDelegate>>>;
46
47 /// Setter for [`delegate`][Self::delegate].
48 ///
49 /// This is a [weak property][objc2::topics::weak_property].
50 ///
51 /// # Safety
52 ///
53 /// This might not be thread-safe.
54 #[unsafe(method(setDelegate:))]
55 #[unsafe(method_family = none)]
56 pub unsafe fn setDelegate(
57 &self,
58 delegate: Option<&ProtocolObject<dyn HMAccessoryBrowserDelegate>>,
59 );
60
61 #[cfg(feature = "HMAccessory")]
62 /// This is the array of HMAccessory objects that represents new
63 /// accessories that were discovered as part of a search session.
64 /// This array is not updated when a search session is not in progress.
65 ///
66 /// This property is not atomic.
67 ///
68 /// # Safety
69 ///
70 /// This might not be thread-safe.
71 #[unsafe(method(discoveredAccessories))]
72 #[unsafe(method_family = none)]
73 pub unsafe fn discoveredAccessories(&self) -> Retained<NSArray<HMAccessory>>;
74
75 /// Starts searching for accessories that are not associated to any home.
76 ///
77 ///
78 /// If any accessories are discovered, updates are sent to the delegate.
79 /// This will scan for the following types of accessories:
80 /// Accessories supporting HomeKit Wireless Accessory Configuration profile
81 /// Accessories supporting HomeKit Accessory Protocol and are already on
82 /// the same infrastructure IP network
83 /// Accessories supporting HomeKit Accessory Protocol on Bluetooth LE transport
84 /// The array of discovered accessories will be updated when this method
85 /// is called, so applications should clear and reload any stored copies
86 /// of that array or previous new accessory objects.
87 #[unsafe(method(startSearchingForNewAccessories))]
88 #[unsafe(method_family = none)]
89 pub unsafe fn startSearchingForNewAccessories(&self);
90
91 /// Stops searching for new accessories.
92 ///
93 ///
94 /// After this method is called, updates will not be sent to the delegate
95 /// if new accessories are found or removed. Scanning may continue for system
96 /// reasons or if other delegates are still in active searching sessions.
97 /// The contents of the array of discovered accessories will not be updated until
98 /// startSearchingForNewAccessories is called.
99 #[unsafe(method(stopSearchingForNewAccessories))]
100 #[unsafe(method_family = none)]
101 pub unsafe fn stopSearchingForNewAccessories(&self);
102 );
103}
104
105/// Methods declared on superclass `NSObject`.
106impl HMAccessoryBrowser {
107 extern_methods!(
108 #[unsafe(method(new))]
109 #[unsafe(method_family = new)]
110 pub unsafe fn new() -> Retained<Self>;
111 );
112}
113
114extern_protocol!(
115 /// This delegate receives updates about new accessories in the home.
116 ///
117 /// See also [Apple's documentation](https://developer.apple.com/documentation/homekit/hmaccessorybrowserdelegate?language=objc)
118 pub unsafe trait HMAccessoryBrowserDelegate: NSObjectProtocol {
119 #[cfg(feature = "HMAccessory")]
120 /// Informs the delegate about new accessories discovered in the home.
121 ///
122 ///
123 /// Parameter `browser`: Sender of the message.
124 ///
125 ///
126 /// Parameter `accessory`: New accessory that was discovered.
127 #[optional]
128 #[unsafe(method(accessoryBrowser:didFindNewAccessory:))]
129 #[unsafe(method_family = none)]
130 unsafe fn accessoryBrowser_didFindNewAccessory(
131 &self,
132 browser: &HMAccessoryBrowser,
133 accessory: &HMAccessory,
134 );
135
136 #[cfg(feature = "HMAccessory")]
137 /// Informs the delegate about new accessories removed from the home.
138 ///
139 ///
140 /// Parameter `browser`: Sender of the message.
141 ///
142 ///
143 /// Parameter `accessory`: Accessory that was previously discovered but are no longer reachable.
144 /// This method is also invoked when an accessory is added to a home.
145 #[optional]
146 #[unsafe(method(accessoryBrowser:didRemoveNewAccessory:))]
147 #[unsafe(method_family = none)]
148 unsafe fn accessoryBrowser_didRemoveNewAccessory(
149 &self,
150 browser: &HMAccessoryBrowser,
151 accessory: &HMAccessory,
152 );
153 }
154);