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