objc2_io_bluetooth/generated/
IOBluetoothUserLib.rs1use core::cell::UnsafeCell;
4use core::ffi::*;
5use core::marker::{PhantomData, PhantomPinned};
6use core::ptr::NonNull;
7#[cfg(feature = "objc2")]
8use objc2::__framework_prelude::*;
9#[cfg(feature = "objc2-core-foundation")]
10use objc2_core_foundation::*;
11
12use crate::*;
13
14pub const kIOBluetoothObjectIDNULL: IOBluetoothObjectID = 0;
16#[repr(C)]
18pub struct IOBluetoothObjectRef {
19 inner: [u8; 0],
20 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
21}
22
23#[cfg(feature = "objc2-core-foundation")]
24cf_type!(
25 unsafe impl IOBluetoothObjectRef {}
26);
27#[cfg(feature = "objc2")]
28cf_objc2_type!(
29 unsafe impl RefEncode<"OpaqueIOBluetoothObjectRef"> for IOBluetoothObjectRef {}
30);
31
32#[repr(C)]
34pub struct IOBluetoothDeviceRef {
35 inner: [u8; 0],
36 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
37}
38
39#[cfg(feature = "objc2-core-foundation")]
40cf_type!(
41 unsafe impl IOBluetoothDeviceRef {}
42);
43#[cfg(feature = "objc2")]
44cf_objc2_type!(
45 unsafe impl RefEncode<"OpaqueIOBluetoothObjectRef"> for IOBluetoothDeviceRef {}
46);
47
48#[repr(C)]
50pub struct IOBluetoothL2CAPChannelRef {
51 inner: [u8; 0],
52 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
53}
54
55#[cfg(feature = "objc2-core-foundation")]
56cf_type!(
57 unsafe impl IOBluetoothL2CAPChannelRef {}
58);
59#[cfg(feature = "objc2")]
60cf_objc2_type!(
61 unsafe impl RefEncode<"OpaqueIOBluetoothObjectRef"> for IOBluetoothL2CAPChannelRef {}
62);
63
64#[repr(C)]
66pub struct IOBluetoothRFCOMMChannelRef {
67 inner: [u8; 0],
68 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
69}
70
71#[cfg(feature = "objc2-core-foundation")]
72cf_type!(
73 unsafe impl IOBluetoothRFCOMMChannelRef {}
74);
75#[cfg(feature = "objc2")]
76cf_objc2_type!(
77 unsafe impl RefEncode<"OpaqueIOBluetoothObjectRef"> for IOBluetoothRFCOMMChannelRef {}
78);
79
80#[repr(C)]
82pub struct IOBluetoothSDPServiceRecordRef {
83 inner: [u8; 0],
84 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
85}
86
87#[cfg(feature = "objc2-core-foundation")]
88cf_type!(
89 unsafe impl IOBluetoothSDPServiceRecordRef {}
90);
91#[cfg(feature = "objc2")]
92cf_objc2_type!(
93 unsafe impl RefEncode<"OpaqueIOBluetoothObjectRef"> for IOBluetoothSDPServiceRecordRef {}
94);
95
96#[repr(C)]
98pub struct IOBluetoothSDPUUIDRef {
99 inner: [u8; 0],
100 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
101}
102
103#[cfg(feature = "objc2-core-foundation")]
104cf_type!(
105 unsafe impl IOBluetoothSDPUUIDRef {}
106);
107#[cfg(feature = "objc2")]
108cf_objc2_type!(
109 unsafe impl RefEncode<"OpaqueIOBluetoothObjectRef"> for IOBluetoothSDPUUIDRef {}
110);
111
112#[repr(C)]
114pub struct IOBluetoothSDPDataElementRef {
115 inner: [u8; 0],
116 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
117}
118
119#[cfg(feature = "objc2-core-foundation")]
120cf_type!(
121 unsafe impl IOBluetoothSDPDataElementRef {}
122);
123#[cfg(feature = "objc2")]
124cf_objc2_type!(
125 unsafe impl RefEncode<"OpaqueIOBluetoothObjectRef"> for IOBluetoothSDPDataElementRef {}
126);
127
128#[repr(C)]
130pub struct IOBluetoothUserNotificationRef {
131 inner: [u8; 0],
132 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
133}
134
135#[cfg(feature = "objc2-core-foundation")]
136cf_type!(
137 unsafe impl IOBluetoothUserNotificationRef {}
138);
139#[cfg(feature = "objc2")]
140cf_objc2_type!(
141 unsafe impl RefEncode<"OpaqueIOBluetoothObjectRef"> for IOBluetoothUserNotificationRef {}
142);
143
144pub type IOBluetoothObjectID = c_ulong;
146
147pub type IOBluetoothDeviceSearchOptions = u32;
149
150#[repr(transparent)]
152#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
153pub struct IOBluetoothDeviceSearchOptionsBits(pub c_uint);
154impl IOBluetoothDeviceSearchOptionsBits {
155 #[doc(alias = "kSearchOptionsNone")]
156 pub const SearchOptionsNone: Self = Self(0);
157 #[doc(alias = "kSearchOptionsAlwaysStartInquiry")]
158 pub const SearchOptionsAlwaysStartInquiry: Self = Self(1 << 0);
159 #[doc(alias = "kSearchOptionsDiscardCachedResults")]
160 pub const SearchOptionsDiscardCachedResults: Self = Self(1 << 1);
161}
162
163#[cfg(feature = "objc2")]
164unsafe impl Encode for IOBluetoothDeviceSearchOptionsBits {
165 const ENCODING: Encoding = c_uint::ENCODING;
166}
167
168#[cfg(feature = "objc2")]
169unsafe impl RefEncode for IOBluetoothDeviceSearchOptionsBits {
170 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
171}
172
173#[cfg(feature = "Bluetooth")]
181#[repr(C)]
182#[derive(Clone, Copy, Debug, PartialEq)]
183pub struct IOBluetoothDeviceSearchDeviceAttributes {
184 pub address: BluetoothDeviceAddress,
185 pub name: BluetoothDeviceName,
186 pub serviceClassMajor: BluetoothServiceClassMajor,
187 pub deviceClassMajor: BluetoothDeviceClassMajor,
188 pub deviceClassMinor: BluetoothDeviceClassMinor,
189}
190
191#[cfg(all(feature = "Bluetooth", feature = "objc2"))]
192unsafe impl Encode for IOBluetoothDeviceSearchDeviceAttributes {
193 const ENCODING: Encoding = Encoding::Struct(
194 "IOBluetoothDeviceSearchDeviceAttributes",
195 &[
196 <BluetoothDeviceAddress>::ENCODING,
197 <BluetoothDeviceName>::ENCODING,
198 <BluetoothServiceClassMajor>::ENCODING,
199 <BluetoothDeviceClassMajor>::ENCODING,
200 <BluetoothDeviceClassMinor>::ENCODING,
201 ],
202 );
203}
204
205#[cfg(all(feature = "Bluetooth", feature = "objc2"))]
206unsafe impl RefEncode for IOBluetoothDeviceSearchDeviceAttributes {
207 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
208}
209
210#[cfg(feature = "Bluetooth")]
217#[repr(C)]
218#[derive(Clone, Copy, Debug, PartialEq)]
219pub struct IOBluetoothDeviceSearchAttributes {
220 pub options: IOBluetoothDeviceSearchOptions,
221 pub maxResults: IOItemCount,
222 pub deviceAttributeCount: IOItemCount,
223 pub attributeList: *mut IOBluetoothDeviceSearchDeviceAttributes,
224}
225
226#[cfg(all(feature = "Bluetooth", feature = "objc2"))]
227unsafe impl Encode for IOBluetoothDeviceSearchAttributes {
228 const ENCODING: Encoding = Encoding::Struct(
229 "IOBluetoothDeviceSearchAttributes",
230 &[
231 <IOBluetoothDeviceSearchOptions>::ENCODING,
232 <IOItemCount>::ENCODING,
233 <IOItemCount>::ENCODING,
234 <*mut IOBluetoothDeviceSearchDeviceAttributes>::ENCODING,
235 ],
236 );
237}
238
239#[cfg(all(feature = "Bluetooth", feature = "objc2"))]
240unsafe impl RefEncode for IOBluetoothDeviceSearchAttributes {
241 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
242}
243
244pub type IOBluetoothDeviceSearchTypes = u32;
246
247#[repr(transparent)]
251#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
252pub struct IOBluetoothDeviceSearchTypesBits(pub c_uint);
253impl IOBluetoothDeviceSearchTypesBits {
254 #[doc(alias = "kIOBluetoothDeviceSearchClassic")]
255 pub const Classic: Self = Self(1);
256 #[doc(alias = "kIOBluetoothDeviceSearchLE")]
257 pub const LE: Self = Self(2);
258}
259
260#[cfg(feature = "objc2")]
261unsafe impl Encode for IOBluetoothDeviceSearchTypesBits {
262 const ENCODING: Encoding = c_uint::ENCODING;
263}
264
265#[cfg(feature = "objc2")]
266unsafe impl RefEncode for IOBluetoothDeviceSearchTypesBits {
267 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
268}
269
270extern "C-unwind" {
271 pub fn IOBluetoothIgnoreHIDDevice(device: Option<&IOBluetoothDeviceRef>);
279}
280
281extern "C-unwind" {
282 pub fn IOBluetoothRemoveIgnoredHIDDevice(device: Option<&IOBluetoothDeviceRef>);
290}
291
292#[repr(transparent)]
294#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
295pub struct IOBluetoothUserNotificationChannelDirection(pub c_uint);
296impl IOBluetoothUserNotificationChannelDirection {
297 #[doc(alias = "kIOBluetoothUserNotificationChannelDirectionAny")]
298 pub const Any: Self = Self(0);
299 #[doc(alias = "kIOBluetoothUserNotificationChannelDirectionIncoming")]
300 pub const Incoming: Self = Self(1);
301 #[doc(alias = "kIOBluetoothUserNotificationChannelDirectionOutgoing")]
302 pub const Outgoing: Self = Self(2);
303}
304
305#[cfg(feature = "objc2")]
306unsafe impl Encode for IOBluetoothUserNotificationChannelDirection {
307 const ENCODING: Encoding = c_uint::ENCODING;
308}
309
310#[cfg(feature = "objc2")]
311unsafe impl RefEncode for IOBluetoothUserNotificationChannelDirection {
312 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
313}
314
315pub type IOBluetoothUserNotificationCallback = Option<
328 unsafe extern "C-unwind" fn(
329 *mut c_void,
330 *mut IOBluetoothUserNotificationRef,
331 *mut IOBluetoothObjectRef,
332 ),
333>;
334
335impl IOBluetoothUserNotificationRef {
336 #[doc(alias = "IOBluetoothUserNotificationUnregister")]
344 #[inline]
345 pub unsafe fn unregister(&self) {
346 extern "C-unwind" {
347 fn IOBluetoothUserNotificationUnregister(
348 notification_ref: &IOBluetoothUserNotificationRef,
349 );
350 }
351 unsafe { IOBluetoothUserNotificationUnregister(self) }
352 }
353}
354
355impl IOBluetoothL2CAPChannelRef {
356 #[doc(alias = "IOBluetoothL2CAPChannelRegisterForChannelCloseNotification")]
378 #[cfg(feature = "objc2-core-foundation")]
379 #[inline]
380 pub unsafe fn register_for_channel_close_notification(
381 &self,
382 callback: IOBluetoothUserNotificationCallback,
383 in_ref_con: *mut c_void,
384 ) -> Option<CFRetained<IOBluetoothUserNotificationRef>> {
385 extern "C-unwind" {
386 fn IOBluetoothL2CAPChannelRegisterForChannelCloseNotification(
387 channel: &IOBluetoothL2CAPChannelRef,
388 callback: IOBluetoothUserNotificationCallback,
389 in_ref_con: *mut c_void,
390 ) -> Option<NonNull<IOBluetoothUserNotificationRef>>;
391 }
392 let ret = unsafe {
393 IOBluetoothL2CAPChannelRegisterForChannelCloseNotification(self, callback, in_ref_con)
394 };
395 ret.map(|ret| unsafe { CFRetained::retain(ret) })
396 }
397}
398
399extern "C-unwind" {
400 #[cfg(feature = "objc2-core-foundation")]
416 #[deprecated]
417 pub fn IOBluetoothAddSCOAudioDevice(
418 device: Option<&IOBluetoothDeviceRef>,
419 config_dict: Option<&CFDictionary>,
420 ) -> IOReturn;
421}
422
423extern "C-unwind" {
424 #[deprecated]
434 pub fn IOBluetoothRemoveSCOAudioDevice(device: Option<&IOBluetoothDeviceRef>) -> IOReturn;
435}
436
437extern "C-unwind" {
438 #[deprecated = "renamed to `IOBluetoothUserNotificationRef::unregister`"]
439 pub fn IOBluetoothUserNotificationUnregister(notification_ref: &IOBluetoothUserNotificationRef);
440}
441
442#[cfg(feature = "objc2-core-foundation")]
443#[deprecated = "renamed to `IOBluetoothL2CAPChannelRef::register_for_channel_close_notification`"]
444#[inline]
445pub unsafe extern "C-unwind" fn IOBluetoothL2CAPChannelRegisterForChannelCloseNotification(
446 channel: &IOBluetoothL2CAPChannelRef,
447 callback: IOBluetoothUserNotificationCallback,
448 in_ref_con: *mut c_void,
449) -> Option<CFRetained<IOBluetoothUserNotificationRef>> {
450 extern "C-unwind" {
451 fn IOBluetoothL2CAPChannelRegisterForChannelCloseNotification(
452 channel: &IOBluetoothL2CAPChannelRef,
453 callback: IOBluetoothUserNotificationCallback,
454 in_ref_con: *mut c_void,
455 ) -> Option<NonNull<IOBluetoothUserNotificationRef>>;
456 }
457 let ret = unsafe {
458 IOBluetoothL2CAPChannelRegisterForChannelCloseNotification(channel, callback, in_ref_con)
459 };
460 ret.map(|ret| unsafe { CFRetained::retain(ret) })
461}