use core::cell::UnsafeCell;
use core::ffi::*;
use core::marker::{PhantomData, PhantomPinned};
use core::ptr::NonNull;
#[cfg(feature = "objc2")]
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-core-foundation")]
use objc2_core_foundation::*;
use crate::*;
pub const kIOBluetoothObjectIDNULL: IOBluetoothObjectID = 0;
#[repr(C)]
pub struct IOBluetoothObjectRef {
inner: [u8; 0],
_p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
}
#[cfg(feature = "objc2-core-foundation")]
cf_type!(
unsafe impl IOBluetoothObjectRef {}
);
#[cfg(feature = "objc2")]
cf_objc2_type!(
unsafe impl RefEncode<"OpaqueIOBluetoothObjectRef"> for IOBluetoothObjectRef {}
);
#[repr(C)]
pub struct IOBluetoothDeviceRef {
inner: [u8; 0],
_p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
}
#[cfg(feature = "objc2-core-foundation")]
cf_type!(
unsafe impl IOBluetoothDeviceRef {}
);
#[cfg(feature = "objc2")]
cf_objc2_type!(
unsafe impl RefEncode<"OpaqueIOBluetoothObjectRef"> for IOBluetoothDeviceRef {}
);
#[repr(C)]
pub struct IOBluetoothL2CAPChannelRef {
inner: [u8; 0],
_p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
}
#[cfg(feature = "objc2-core-foundation")]
cf_type!(
unsafe impl IOBluetoothL2CAPChannelRef {}
);
#[cfg(feature = "objc2")]
cf_objc2_type!(
unsafe impl RefEncode<"OpaqueIOBluetoothObjectRef"> for IOBluetoothL2CAPChannelRef {}
);
#[repr(C)]
pub struct IOBluetoothRFCOMMChannelRef {
inner: [u8; 0],
_p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
}
#[cfg(feature = "objc2-core-foundation")]
cf_type!(
unsafe impl IOBluetoothRFCOMMChannelRef {}
);
#[cfg(feature = "objc2")]
cf_objc2_type!(
unsafe impl RefEncode<"OpaqueIOBluetoothObjectRef"> for IOBluetoothRFCOMMChannelRef {}
);
#[repr(C)]
pub struct IOBluetoothSDPServiceRecordRef {
inner: [u8; 0],
_p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
}
#[cfg(feature = "objc2-core-foundation")]
cf_type!(
unsafe impl IOBluetoothSDPServiceRecordRef {}
);
#[cfg(feature = "objc2")]
cf_objc2_type!(
unsafe impl RefEncode<"OpaqueIOBluetoothObjectRef"> for IOBluetoothSDPServiceRecordRef {}
);
#[repr(C)]
pub struct IOBluetoothSDPUUIDRef {
inner: [u8; 0],
_p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
}
#[cfg(feature = "objc2-core-foundation")]
cf_type!(
unsafe impl IOBluetoothSDPUUIDRef {}
);
#[cfg(feature = "objc2")]
cf_objc2_type!(
unsafe impl RefEncode<"OpaqueIOBluetoothObjectRef"> for IOBluetoothSDPUUIDRef {}
);
#[repr(C)]
pub struct IOBluetoothSDPDataElementRef {
inner: [u8; 0],
_p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
}
#[cfg(feature = "objc2-core-foundation")]
cf_type!(
unsafe impl IOBluetoothSDPDataElementRef {}
);
#[cfg(feature = "objc2")]
cf_objc2_type!(
unsafe impl RefEncode<"OpaqueIOBluetoothObjectRef"> for IOBluetoothSDPDataElementRef {}
);
#[repr(C)]
pub struct IOBluetoothUserNotificationRef {
inner: [u8; 0],
_p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
}
#[cfg(feature = "objc2-core-foundation")]
cf_type!(
unsafe impl IOBluetoothUserNotificationRef {}
);
#[cfg(feature = "objc2")]
cf_objc2_type!(
unsafe impl RefEncode<"OpaqueIOBluetoothObjectRef"> for IOBluetoothUserNotificationRef {}
);
pub type IOBluetoothObjectID = c_ulong;
pub type IOBluetoothDeviceSearchOptions = u32;
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct IOBluetoothDeviceSearchOptionsBits(pub c_uint);
impl IOBluetoothDeviceSearchOptionsBits {
#[doc(alias = "kSearchOptionsNone")]
pub const SearchOptionsNone: Self = Self(0);
#[doc(alias = "kSearchOptionsAlwaysStartInquiry")]
pub const SearchOptionsAlwaysStartInquiry: Self = Self(1 << 0);
#[doc(alias = "kSearchOptionsDiscardCachedResults")]
pub const SearchOptionsDiscardCachedResults: Self = Self(1 << 1);
}
#[cfg(feature = "objc2")]
unsafe impl Encode for IOBluetoothDeviceSearchOptionsBits {
const ENCODING: Encoding = c_uint::ENCODING;
}
#[cfg(feature = "objc2")]
unsafe impl RefEncode for IOBluetoothDeviceSearchOptionsBits {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
#[cfg(feature = "Bluetooth")]
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct IOBluetoothDeviceSearchDeviceAttributes {
pub address: BluetoothDeviceAddress,
pub name: BluetoothDeviceName,
pub serviceClassMajor: BluetoothServiceClassMajor,
pub deviceClassMajor: BluetoothDeviceClassMajor,
pub deviceClassMinor: BluetoothDeviceClassMinor,
}
#[cfg(all(feature = "Bluetooth", feature = "objc2"))]
unsafe impl Encode for IOBluetoothDeviceSearchDeviceAttributes {
const ENCODING: Encoding = Encoding::Struct(
"IOBluetoothDeviceSearchDeviceAttributes",
&[
<BluetoothDeviceAddress>::ENCODING,
<BluetoothDeviceName>::ENCODING,
<BluetoothServiceClassMajor>::ENCODING,
<BluetoothDeviceClassMajor>::ENCODING,
<BluetoothDeviceClassMinor>::ENCODING,
],
);
}
#[cfg(all(feature = "Bluetooth", feature = "objc2"))]
unsafe impl RefEncode for IOBluetoothDeviceSearchDeviceAttributes {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
#[cfg(feature = "Bluetooth")]
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct IOBluetoothDeviceSearchAttributes {
pub options: IOBluetoothDeviceSearchOptions,
pub maxResults: IOItemCount,
pub deviceAttributeCount: IOItemCount,
pub attributeList: *mut IOBluetoothDeviceSearchDeviceAttributes,
}
#[cfg(all(feature = "Bluetooth", feature = "objc2"))]
unsafe impl Encode for IOBluetoothDeviceSearchAttributes {
const ENCODING: Encoding = Encoding::Struct(
"IOBluetoothDeviceSearchAttributes",
&[
<IOBluetoothDeviceSearchOptions>::ENCODING,
<IOItemCount>::ENCODING,
<IOItemCount>::ENCODING,
<*mut IOBluetoothDeviceSearchDeviceAttributes>::ENCODING,
],
);
}
#[cfg(all(feature = "Bluetooth", feature = "objc2"))]
unsafe impl RefEncode for IOBluetoothDeviceSearchAttributes {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
pub type IOBluetoothDeviceSearchTypes = u32;
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct IOBluetoothDeviceSearchTypesBits(pub c_uint);
impl IOBluetoothDeviceSearchTypesBits {
#[doc(alias = "kIOBluetoothDeviceSearchClassic")]
pub const Classic: Self = Self(1);
#[doc(alias = "kIOBluetoothDeviceSearchLE")]
pub const LE: Self = Self(2);
}
#[cfg(feature = "objc2")]
unsafe impl Encode for IOBluetoothDeviceSearchTypesBits {
const ENCODING: Encoding = c_uint::ENCODING;
}
#[cfg(feature = "objc2")]
unsafe impl RefEncode for IOBluetoothDeviceSearchTypesBits {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern "C-unwind" {
pub fn IOBluetoothIgnoreHIDDevice(device: Option<&IOBluetoothDeviceRef>);
}
extern "C-unwind" {
pub fn IOBluetoothRemoveIgnoredHIDDevice(device: Option<&IOBluetoothDeviceRef>);
}
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct IOBluetoothUserNotificationChannelDirection(pub c_uint);
impl IOBluetoothUserNotificationChannelDirection {
#[doc(alias = "kIOBluetoothUserNotificationChannelDirectionAny")]
pub const Any: Self = Self(0);
#[doc(alias = "kIOBluetoothUserNotificationChannelDirectionIncoming")]
pub const Incoming: Self = Self(1);
#[doc(alias = "kIOBluetoothUserNotificationChannelDirectionOutgoing")]
pub const Outgoing: Self = Self(2);
}
#[cfg(feature = "objc2")]
unsafe impl Encode for IOBluetoothUserNotificationChannelDirection {
const ENCODING: Encoding = c_uint::ENCODING;
}
#[cfg(feature = "objc2")]
unsafe impl RefEncode for IOBluetoothUserNotificationChannelDirection {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
pub type IOBluetoothUserNotificationCallback = Option<
unsafe extern "C-unwind" fn(
*mut c_void,
*mut IOBluetoothUserNotificationRef,
*mut IOBluetoothObjectRef,
),
>;
impl IOBluetoothUserNotificationRef {
#[doc(alias = "IOBluetoothUserNotificationUnregister")]
#[inline]
pub unsafe fn unregister(&self) {
extern "C-unwind" {
fn IOBluetoothUserNotificationUnregister(
notification_ref: &IOBluetoothUserNotificationRef,
);
}
unsafe { IOBluetoothUserNotificationUnregister(self) }
}
}
impl IOBluetoothL2CAPChannelRef {
#[doc(alias = "IOBluetoothL2CAPChannelRegisterForChannelCloseNotification")]
#[cfg(feature = "objc2-core-foundation")]
#[inline]
pub unsafe fn register_for_channel_close_notification(
&self,
callback: IOBluetoothUserNotificationCallback,
in_ref_con: *mut c_void,
) -> Option<CFRetained<IOBluetoothUserNotificationRef>> {
extern "C-unwind" {
fn IOBluetoothL2CAPChannelRegisterForChannelCloseNotification(
channel: &IOBluetoothL2CAPChannelRef,
callback: IOBluetoothUserNotificationCallback,
in_ref_con: *mut c_void,
) -> Option<NonNull<IOBluetoothUserNotificationRef>>;
}
let ret = unsafe {
IOBluetoothL2CAPChannelRegisterForChannelCloseNotification(self, callback, in_ref_con)
};
ret.map(|ret| unsafe { CFRetained::retain(ret) })
}
}
extern "C-unwind" {
#[cfg(feature = "objc2-core-foundation")]
#[deprecated]
pub fn IOBluetoothAddSCOAudioDevice(
device: Option<&IOBluetoothDeviceRef>,
config_dict: Option<&CFDictionary>,
) -> IOReturn;
}
extern "C-unwind" {
#[deprecated]
pub fn IOBluetoothRemoveSCOAudioDevice(device: Option<&IOBluetoothDeviceRef>) -> IOReturn;
}
extern "C-unwind" {
#[deprecated = "renamed to `IOBluetoothUserNotificationRef::unregister`"]
pub fn IOBluetoothUserNotificationUnregister(notification_ref: &IOBluetoothUserNotificationRef);
}
#[cfg(feature = "objc2-core-foundation")]
#[deprecated = "renamed to `IOBluetoothL2CAPChannelRef::register_for_channel_close_notification`"]
#[inline]
pub unsafe extern "C-unwind" fn IOBluetoothL2CAPChannelRegisterForChannelCloseNotification(
channel: &IOBluetoothL2CAPChannelRef,
callback: IOBluetoothUserNotificationCallback,
in_ref_con: *mut c_void,
) -> Option<CFRetained<IOBluetoothUserNotificationRef>> {
extern "C-unwind" {
fn IOBluetoothL2CAPChannelRegisterForChannelCloseNotification(
channel: &IOBluetoothL2CAPChannelRef,
callback: IOBluetoothUserNotificationCallback,
in_ref_con: *mut c_void,
) -> Option<NonNull<IOBluetoothUserNotificationRef>>;
}
let ret = unsafe {
IOBluetoothL2CAPChannelRegisterForChannelCloseNotification(channel, callback, in_ref_con)
};
ret.map(|ret| unsafe { CFRetained::retain(ret) })
}