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 #[unsafe(method(delegate))]
36 #[unsafe(method_family = none)]
37 pub unsafe fn delegate(
38 &self,
39 ) -> Option<Retained<ProtocolObject<dyn HMAccessoryBrowserDelegate>>>;
40
41 /// This is a [weak property][objc2::topics::weak_property].
42 /// Setter for [`delegate`][Self::delegate].
43 #[unsafe(method(setDelegate:))]
44 #[unsafe(method_family = none)]
45 pub unsafe fn setDelegate(
46 &self,
47 delegate: Option<&ProtocolObject<dyn HMAccessoryBrowserDelegate>>,
48 );
49
50 #[cfg(feature = "HMAccessory")]
51 /// This is the array of HMAccessory objects that represents new
52 /// accessories that were discovered as part of a search session.
53 /// This array is not updated when a search session is not in progress.
54 #[unsafe(method(discoveredAccessories))]
55 #[unsafe(method_family = none)]
56 pub unsafe fn discoveredAccessories(&self) -> Retained<NSArray<HMAccessory>>;
57
58 /// Starts searching for accessories that are not associated to any home.
59 ///
60 ///
61 /// If any accessories are discovered, updates are sent to the delegate.
62 /// This will scan for the following types of accessories:
63 /// Accessories supporting HomeKit Wireless Accessory Configuration profile
64 /// Accessories supporting HomeKit Accessory Protocol and are already on
65 /// the same infrastructure IP network
66 /// Accessories supporting HomeKit Accessory Protocol on Bluetooth LE transport
67 /// The array of discovered accessories will be updated when this method
68 /// is called, so applications should clear and reload any stored copies
69 /// of that array or previous new accessory objects.
70 #[unsafe(method(startSearchingForNewAccessories))]
71 #[unsafe(method_family = none)]
72 pub unsafe fn startSearchingForNewAccessories(&self);
73
74 /// Stops searching for new accessories.
75 ///
76 ///
77 /// After this method is called, updates will not be sent to the delegate
78 /// if new accessories are found or removed. Scanning may continue for system
79 /// reasons or if other delegates are still in active searching sessions.
80 /// The contents of the array of discovered accessories will not be updated until
81 /// startSearchingForNewAccessories is called.
82 #[unsafe(method(stopSearchingForNewAccessories))]
83 #[unsafe(method_family = none)]
84 pub unsafe fn stopSearchingForNewAccessories(&self);
85 );
86}
87
88/// Methods declared on superclass `NSObject`.
89impl HMAccessoryBrowser {
90 extern_methods!(
91 #[unsafe(method(new))]
92 #[unsafe(method_family = new)]
93 pub unsafe fn new() -> Retained<Self>;
94 );
95}
96
97extern_protocol!(
98 /// This delegate receives updates about new accessories in the home.
99 ///
100 /// See also [Apple's documentation](https://developer.apple.com/documentation/homekit/hmaccessorybrowserdelegate?language=objc)
101 pub unsafe trait HMAccessoryBrowserDelegate: NSObjectProtocol {
102 #[cfg(feature = "HMAccessory")]
103 /// Informs the delegate about new accessories discovered in the home.
104 ///
105 ///
106 /// Parameter `browser`: Sender of the message.
107 ///
108 ///
109 /// Parameter `accessory`: New accessory that was discovered.
110 #[optional]
111 #[unsafe(method(accessoryBrowser:didFindNewAccessory:))]
112 #[unsafe(method_family = none)]
113 unsafe fn accessoryBrowser_didFindNewAccessory(
114 &self,
115 browser: &HMAccessoryBrowser,
116 accessory: &HMAccessory,
117 );
118
119 #[cfg(feature = "HMAccessory")]
120 /// Informs the delegate about new accessories removed from the home.
121 ///
122 ///
123 /// Parameter `browser`: Sender of the message.
124 ///
125 ///
126 /// Parameter `accessory`: Accessory that was previously discovered but are no longer reachable.
127 /// This method is also invoked when an accessory is added to a home.
128 #[optional]
129 #[unsafe(method(accessoryBrowser:didRemoveNewAccessory:))]
130 #[unsafe(method_family = none)]
131 unsafe fn accessoryBrowser_didRemoveNewAccessory(
132 &self,
133 browser: &HMAccessoryBrowser,
134 accessory: &HMAccessory,
135 );
136 }
137);