objc2_io_bluetooth/generated/objc2/IOBluetoothHostController.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::*;
6#[cfg(feature = "objc2-foundation")]
7use objc2_foundation::*;
8
9use crate::*;
10
11extern_class!(
12 /// This class is a representation of a Bluetooth Host Controller Interface that is present on the
13 /// local computer (either plugged in externally or available internally).
14 ///
15 /// This object can be used to ask a Bluetooth HCI for certain pieces of information, and be used to make
16 /// it perform certain functions.
17 ///
18 /// See also [Apple's documentation](https://developer.apple.com/documentation/iobluetooth/iobluetoothhostcontroller?language=objc)
19 #[unsafe(super(NSObject))]
20 #[derive(Debug, PartialEq, Eq, Hash)]
21 pub struct IOBluetoothHostController;
22);
23
24extern_conformance!(
25 unsafe impl NSObjectProtocol for IOBluetoothHostController {}
26);
27
28impl IOBluetoothHostController {
29 extern_methods!(
30 #[unsafe(method(delegate))]
31 #[unsafe(method_family = none)]
32 pub unsafe fn delegate(&self) -> Option<Retained<AnyObject>>;
33
34 /// Setter for [`delegate`][Self::delegate].
35 ///
36 /// This is a [weak property][objc2::topics::weak_property].
37 ///
38 /// # Safety
39 ///
40 /// - `delegate` should be of the correct type.
41 /// - `delegate` might not allow `None`.
42 #[unsafe(method(setDelegate:))]
43 #[unsafe(method_family = none)]
44 pub unsafe fn setDelegate(&self, delegate: Option<&AnyObject>);
45
46 /// Gets the default HCI controller object.
47 ///
48 /// Returns: A (autoreleased) pointer to the created IOBluetoothHostController object.
49 #[unsafe(method(defaultController))]
50 #[unsafe(method_family = none)]
51 pub unsafe fn defaultController() -> Option<Retained<Self>>;
52
53 #[cfg(feature = "Bluetooth")]
54 /// Gets the controller power state
55 ///
56 /// Returns: The current controller's power state. This will be 1 for on, or 0 for off. Only Apple Bluetooth adapters support power off
57 #[unsafe(method(powerState))]
58 #[unsafe(method_family = none)]
59 pub unsafe fn powerState(&self) -> BluetoothHCIPowerState;
60
61 #[cfg(feature = "Bluetooth")]
62 /// Gets the current class of device value.
63 ///
64 /// Returns: Returns the current class of device value.
65 #[unsafe(method(classOfDevice))]
66 #[unsafe(method_family = none)]
67 pub unsafe fn classOfDevice(&self) -> BluetoothClassOfDevice;
68
69 #[cfg(all(feature = "Bluetooth", feature = "objc2-foundation"))]
70 /// Sets the current class of device value, for the specified amount of time. Note that the time interval *must*
71 /// be set and valid. The range of acceptable values is 30-120 seconds. Anything above or below will be rounded
72 /// up, or down, as appropriate.
73 ///
74 /// Returns: Returns the whether setting the class of device value was successful. 0 if success, error code otherwise.
75 #[unsafe(method(setClassOfDevice:forTimeInterval:))]
76 #[unsafe(method_family = none)]
77 pub unsafe fn setClassOfDevice_forTimeInterval(
78 &self,
79 class_of_device: BluetoothClassOfDevice,
80 seconds: NSTimeInterval,
81 ) -> IOReturn;
82
83 #[cfg(feature = "objc2-foundation")]
84 /// Convience routine to get the HCI controller's Bluetooth address as an NSString object.
85 ///
86 /// Returns: Returns NSString *. nil if the address could not be retrieved.
87 #[unsafe(method(addressAsString))]
88 #[unsafe(method_family = none)]
89 pub unsafe fn addressAsString(&self) -> Option<Retained<NSString>>;
90
91 #[cfg(feature = "objc2-foundation")]
92 /// Gets the "friendly" name of HCI controller.
93 ///
94 /// Returns: Returns NSString with the device name, nil if there is not one or it cannot be read.
95 #[unsafe(method(nameAsString))]
96 #[unsafe(method_family = none)]
97 pub unsafe fn nameAsString(&self) -> Option<Retained<NSString>>;
98 );
99}
100
101/// Methods declared on superclass `NSObject`.
102impl IOBluetoothHostController {
103 extern_methods!(
104 #[unsafe(method(init))]
105 #[unsafe(method_family = init)]
106 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
107
108 #[unsafe(method(new))]
109 #[unsafe(method_family = new)]
110 pub unsafe fn new() -> Retained<Self>;
111 );
112}
113
114mod private_NSObjectIOBluetoothHostControllerDelegate {
115 pub trait Sealed {}
116}
117
118/// Category "IOBluetoothHostControllerDelegate" on [`NSObject`].
119///
120/// This category on NSObject describes the delegate methods for the IOBluetoothHostController object. All
121/// methods are optional, but it is highly recommended you implement them all. Do NOT invoke remote name
122/// requests on found IOBluetoothDevice objects unless the controller object has been stopped. Doing so may
123/// deadlock your process.
124#[doc(alias = "IOBluetoothHostControllerDelegate")]
125pub unsafe trait NSObjectIOBluetoothHostControllerDelegate:
126 ClassType + Sized + private_NSObjectIOBluetoothHostControllerDelegate::Sealed
127{
128 extern_methods!(
129 #[cfg(all(
130 feature = "Bluetooth",
131 feature = "IOBluetoothDevice",
132 feature = "IOBluetoothObject"
133 ))]
134 /// This delegate gets invoked when an RSSI command complete event occurs. This could occur because you
135 /// invoked it by issuing an -readRSSIForDevice: command, or someone else did from another app on the
136 /// same controller.
137 ///
138 /// Parameter `sender`: Controller object that sent this delegate message.
139 ///
140 /// # Safety
141 ///
142 /// - `controller` should be of the correct type.
143 /// - `controller` might not allow `None`.
144 /// - `device` might not allow `None`.
145 /// - `info` must be a valid pointer.
146 #[unsafe(method(readRSSIForDeviceComplete:device:info:error:))]
147 #[unsafe(method_family = none)]
148 unsafe fn readRSSIForDeviceComplete_device_info_error(
149 &self,
150 controller: Option<&AnyObject>,
151 device: Option<&IOBluetoothDevice>,
152 info: *mut BluetoothHCIRSSIInfo,
153 error: IOReturn,
154 );
155
156 #[cfg(all(
157 feature = "Bluetooth",
158 feature = "IOBluetoothDevice",
159 feature = "IOBluetoothObject"
160 ))]
161 /// This delegate gets invoked when an read link quality command complete event occurs. This could occur because you
162 /// invoked it by issuing an -readLinkQualityForDevice: command, or someone else did from another app on the
163 /// same controller.
164 ///
165 /// Parameter `sender`: Controller object that sent this delegate message.
166 ///
167 /// # Safety
168 ///
169 /// - `controller` should be of the correct type.
170 /// - `controller` might not allow `None`.
171 /// - `device` might not allow `None`.
172 /// - `info` must be a valid pointer.
173 #[unsafe(method(readLinkQualityForDeviceComplete:device:info:error:))]
174 #[unsafe(method_family = none)]
175 unsafe fn readLinkQualityForDeviceComplete_device_info_error(
176 &self,
177 controller: Option<&AnyObject>,
178 device: Option<&IOBluetoothDevice>,
179 info: *mut BluetoothHCILinkQualityInfo,
180 error: IOReturn,
181 );
182 );
183}
184
185impl private_NSObjectIOBluetoothHostControllerDelegate::Sealed for NSObject {}
186unsafe impl NSObjectIOBluetoothHostControllerDelegate for NSObject {}
187
188extern "C" {
189 /// [Apple's documentation](https://developer.apple.com/documentation/iobluetooth/iobluetoothhostcontrollerpoweredonnotification?language=objc)
190 #[cfg(feature = "objc2-foundation")]
191 pub static IOBluetoothHostControllerPoweredOnNotification: Option<&'static NSString>;
192}
193
194extern "C" {
195 /// [Apple's documentation](https://developer.apple.com/documentation/iobluetooth/iobluetoothhostcontrollerpoweredoffnotification?language=objc)
196 #[cfg(feature = "objc2-foundation")]
197 pub static IOBluetoothHostControllerPoweredOffNotification: Option<&'static NSString>;
198}