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