#[repr(C)]pub struct IOBluetoothDevice { /* private fields */ }IOBluetoothDevice and objc2 and IOBluetoothObject only.Expand description
An instance of IOBluetoothDevice represents a single remote Bluetooth device.
An IOBluetoothDevice object may exist independent of the existence of a baseband connection with the target device. Using this object, a client can request creation and destruction of baseband connections, and request the opening of L2CAP and RFCOMM channels on the remote device. Many of the other APIs in the IOBluetooth framework will return this object, or it’s C counterpart (IOBluetoothDeviceRef).
See also Apple’s documentation
Implementations§
Source§impl IOBluetoothDevice
impl IOBluetoothDevice
Sourcepub unsafe fn registerForConnectNotifications_selector(
observer: Option<&AnyObject>,
in_selector: Option<Sel>,
) -> Option<Retained<IOBluetoothUserNotification>>
Available on crate feature IOBluetoothUserNotification only.
pub unsafe fn registerForConnectNotifications_selector( observer: Option<&AnyObject>, in_selector: Option<Sel>, ) -> Option<Retained<IOBluetoothUserNotification>>
IOBluetoothUserNotification only.Allows a client to register for device connect notifications for any connection.
The given selector will be called on the target observer whenever any device connection is made. The selector should accept two arguments. The first is the user notification object. The second is the device that was connected.
Parameter observer: Target observer object
Parameter inSelector: Selector to be sent to the observer when a new connection is made
Returns: Returns an IOBluetoothUserNotification representing the outstanding device connect notification. To unregister the notification, call -unregister on the returned IOBluetoothUserNotification object. If an error is encountered creating the notification, nil is returned. The returned IOBluetoothUserNotification object will be valid for as long as the notification is registered. It is not necessary to retain the result. Once -unregister is called on it, it will no longer be valid.
Sourcepub unsafe fn registerForDisconnectNotification_selector(
&self,
observer: Option<&AnyObject>,
in_selector: Option<Sel>,
) -> Option<Retained<IOBluetoothUserNotification>>
Available on crate feature IOBluetoothUserNotification only.
pub unsafe fn registerForDisconnectNotification_selector( &self, observer: Option<&AnyObject>, in_selector: Option<Sel>, ) -> Option<Retained<IOBluetoothUserNotification>>
IOBluetoothUserNotification only.Allows a client to register for device disconnect notification.
The given selector will be called on the target observer when the target device’s connection is closed. The selector should contain two arguments. The first is the user notification object. The second is the IOBluetoothDevice that was disconnected.
Parameter observer: Target observer object
Parameter inSelector: Selector to be sent to the observer when the connection is destroyed
Returns: Returns an IOBluetoothUserNotification representing the outstanding device disconnect notification. To unregister the notification, call -unregister of the returned IOBluetoothUserNotification object. If an error is encountered creating the notification, nil is returned.
Sourcepub unsafe fn deviceWithAddress(
address: *const BluetoothDeviceAddress,
) -> Option<Retained<Self>>
Available on crate feature Bluetooth only.
pub unsafe fn deviceWithAddress( address: *const BluetoothDeviceAddress, ) -> Option<Retained<Self>>
Bluetooth only.Returns the IOBluetoothDevice object for the given BluetoothDeviceAddress
Within a single application, there will be only one instance of IOBluetoothDevice for a given remote device address.
Parameter address: Pointer to a BluetoothDeviceAddress for which an IOBluetoothDevice instance is desired
Returns: Returns the IOBluetoothDevice object for the given BluetoothDeviceAddress
pub unsafe fn withAddress( address: *const BluetoothDeviceAddress, ) -> Option<Retained<Self>>
Bluetooth only.Sourcepub unsafe fn deviceWithAddressString(
address: Option<&NSString>,
) -> Option<Retained<Self>>
Available on crate feature objc2-foundation only.
pub unsafe fn deviceWithAddressString( address: Option<&NSString>, ) -> Option<Retained<Self>>
objc2-foundation only.Returns the IOBluetoothDevice object for the given BluetoothDeviceAddress
Within a single application, there will be only one instance of IOBluetoothDevice for a given remote device address.
Parameter address: Pointer to an NSString containing the BD_ADDR for which an IOBluetoothDevice instance is desired. The string should be of the form xx:xx:xx:xx:xx:xx
Returns: Returns the IOBluetoothDevice object for the given BluetoothDeviceAddress
Sourcepub unsafe fn withDeviceRef(
device_ref: Option<&IOBluetoothDeviceRef>,
) -> Option<Retained<Self>>
👎DeprecatedAvailable on crate feature IOBluetoothUserLib only.
pub unsafe fn withDeviceRef( device_ref: Option<&IOBluetoothDeviceRef>, ) -> Option<Retained<Self>>
IOBluetoothUserLib only.Method call to convert an IOBluetoothDeviceRef into an IOBluetoothDevice *.
IOBluetoothDeviceRef and it’s API are deprecated. An IOBluetoothDeviceRef can be cast to a IOBluetoothDevice *
Parameter deviceRef: IOBluetoothDeviceRef for which an IOBluetoothDevice * is desired.
Returns: Returns the IOBluetoothDevice * for the given IOBluetoothDeviceRef.
Sourcepub unsafe fn getDeviceRef(&self) -> Option<Retained<IOBluetoothDeviceRef>>
👎DeprecatedAvailable on crate feature IOBluetoothUserLib only.
pub unsafe fn getDeviceRef(&self) -> Option<Retained<IOBluetoothDeviceRef>>
IOBluetoothUserLib only.Returns an IOBluetoothDeviceRef representation of the target IOBluetoothDevice object.
IOBluetoothDeviceRef and it’s API are deprecated. An IOBluetoothDeviceRef can be cast to a IOBluetoothDevice *
Returns: Returns an IOBluetoothDeviceRef representation of the target IOBluetoothDevice object.
Sourcepub unsafe fn openL2CAPChannelSync_withPSM_delegate(
&self,
new_channel: Option<&mut Option<Retained<IOBluetoothL2CAPChannel>>>,
psm: BluetoothL2CAPPSM,
channel_delegate: Option<&AnyObject>,
) -> c_int
Available on crate features Bluetooth and IOBluetoothL2CAPChannel only.
pub unsafe fn openL2CAPChannelSync_withPSM_delegate( &self, new_channel: Option<&mut Option<Retained<IOBluetoothL2CAPChannel>>>, psm: BluetoothL2CAPPSM, channel_delegate: Option<&AnyObject>, ) -> c_int
Bluetooth and IOBluetoothL2CAPChannel only.Opens a new L2CAP channel to the target device. Returns only after the channel is opened.
This method will begin the process of opening a new L2CAP channel to the target device. The baseband connection to the device will be opened if it is not open already. The L2CAP channel open process will not complete until the client has registered an incoming data listener on the new channel. This prevents a situation where the channel succeeds in being configured and opened and receives data before the client is listening and is ready for it.
NOTE: This method is only available in Mac OS X 10.2.5 (Bluetooth v1.2) or later.
Parameter newChannel: A pointer to an IOBluetoothL2CAPChannel object to receive the L2CAP channel
requested to be opened. The newChannel pointer will only be set if
kIOReturnSuccess is returned.
Parameter withPSM: The L2CAP PSM value for the new channel.
Parameter channelDelegate: the object that will play the role of delegate for the channel.
A channel delegate is the object the l2cap uses as target for data and events. The
developer will implement only the the methods he/she is interested in. A list of the
possible methods is at the end of the file “IOBluetoothL2CAPChannel.h” in the definition
of the protocol IOBluetoothL2CAPChannelDelegate.
Returns: Returns kIOReturnSuccess if the open process was successfully started (or if an existing L2CAP channel was found).
Sourcepub unsafe fn openL2CAPChannelAsync_withPSM_delegate(
&self,
new_channel: Option<&mut Option<Retained<IOBluetoothL2CAPChannel>>>,
psm: BluetoothL2CAPPSM,
channel_delegate: Option<&AnyObject>,
) -> c_int
Available on crate features Bluetooth and IOBluetoothL2CAPChannel only.
pub unsafe fn openL2CAPChannelAsync_withPSM_delegate( &self, new_channel: Option<&mut Option<Retained<IOBluetoothL2CAPChannel>>>, psm: BluetoothL2CAPPSM, channel_delegate: Option<&AnyObject>, ) -> c_int
Bluetooth and IOBluetoothL2CAPChannel only.Opens a new L2CAP channel to the target device. Returns immediately after starting the opening process.
This method will begin the process of opening a new L2CAP channel to the target device. The baseband connection to the device will be opened if it is not open already. The L2CAP channel open process will not complete until the client has registered an incoming data listener on the new channel. This prevents a situation where the channel succeeds in being configured and opened and receives data before the client is listening and is ready for it.
NOTE: This method is only available in Mac OS X 10.2.5 (Bluetooth v1.2) or later.
Parameter newChannel: A pointer to an IOBluetoothL2CAPChannel object to receive the L2CAP channel
requested to be opened. The newChannel pointer will only be set if
kIOReturnSuccess is returned.
Parameter psm: The L2CAP PSM value for the new channel.
Parameter channelDelegate: the object that will play the role of delegate for the channel.
A channel delegate is the object the l2cap uses as target for data and events. The
developer will implement only the the methods he/she is interested in. A list of the
possible methods is at the end of the file “IOBluetoothL2CAPChannel.h” in the definition
of the protocol IOBluetoothL2CAPChannelDelegate.
Returns: Returns kIOReturnSuccess if the open process was successfully started (or if an existing L2CAP channel was found).
Sourcepub unsafe fn openL2CAPChannel_findExisting_newChannel(
&self,
psm: BluetoothL2CAPPSM,
find_existing: bool,
new_channel: Option<&mut Option<Retained<IOBluetoothL2CAPChannel>>>,
) -> c_int
👎DeprecatedAvailable on crate features Bluetooth and IOBluetoothL2CAPChannel only.
pub unsafe fn openL2CAPChannel_findExisting_newChannel( &self, psm: BluetoothL2CAPPSM, find_existing: bool, new_channel: Option<&mut Option<Retained<IOBluetoothL2CAPChannel>>>, ) -> c_int
Bluetooth and IOBluetoothL2CAPChannel only.Opens a new L2CAP channel to the target device. Returns immedialty after starting the opening process.
This method will begin the process of opening a new L2CAP channel to the target device. The baseband connection to the device will be opened if it is not open already. The L2CAP channel open process will not complete until the client has registered an incoming data listener on the new channel. This prevents a situation where the channel succeeds in being configured and opened and receives data before the client is listening and is ready for it.
Parameter psm: The L2CAP PSM value for the new channel.
Parameter findExisting: This value should be set to TRUE if it should look for an existing channel
with the PSM. Typically this value will be FALSE. It should be TRUE only
in the case where a single channel is allowed by the spec for the given PSM.
Parameter newChannel: A pointer to an IOBluetoothL2CAPChannel object to receive the L2CAP channel
requested to be opened. The newChannel pointer will only be set if
kIOReturnSuccess is returned.
Returns: Returns kIOReturnSuccess if the open process was successfully started (or if an existing L2CAP channel was found).
Sourcepub unsafe fn sendL2CAPEchoRequest_length(
&self,
data: *mut c_void,
length: u16,
) -> c_int
pub unsafe fn sendL2CAPEchoRequest_length( &self, data: *mut c_void, length: u16, ) -> c_int
Send an echo request over the L2CAP connection to a remote device.
The current implementation returns when the request has been sent, but does not indicate when a response is received. Also, the baseband connection must be up for the echo request to be sent. In the future, this method will also open the connection if necessary. The API will be updated to allow the client to be informed when the echo response has been received (both synchronously and asynchronously).
Parameter data: (void *) - Pointer to buffer to send.
Parameter length: (UInt16) - Length of the buffer to send
Returns: Returns kIOReturnSuccess if the echo request was able to be sent.
Sourcepub unsafe fn openRFCOMMChannel_channel(
&self,
channel_id: BluetoothRFCOMMChannelID,
rfcomm_channel: Option<&mut Option<Retained<IOBluetoothRFCOMMChannel>>>,
) -> c_int
👎DeprecatedAvailable on crate features Bluetooth and IOBluetoothRFCOMMChannel only.
pub unsafe fn openRFCOMMChannel_channel( &self, channel_id: BluetoothRFCOMMChannelID, rfcomm_channel: Option<&mut Option<Retained<IOBluetoothRFCOMMChannel>>>, ) -> c_int
Bluetooth and IOBluetoothRFCOMMChannel only.Opens a new RFCOMM channel to the target device. Returns only once the channel is open or failed to open.
This method will begin the process of opening a new RFCOMM channel to the target device. The baseband connection to the device will be opened if it is not open already. The RFCOMM channel open process will not complete until the client has registered an incoming data listener on the new channel.
Parameter channelID: The RFCOMM channel ID for the new channel.
Parameter rfcommChannel: A pointer to an IOBluetoothRFCOMMChannel object to receive the RFCOMM channel
requested to be opened. The rfcommChannel pointer will only be set if
kIOReturnSuccess is returned.
Returns: Returns kIOReturnSuccess if the open process was successfully started (or if an existing RFCOMM channel was found).
Sourcepub unsafe fn openRFCOMMChannelSync_withChannelID_delegate(
&self,
rfcomm_channel: Option<&mut Option<Retained<IOBluetoothRFCOMMChannel>>>,
channel_id: BluetoothRFCOMMChannelID,
channel_delegate: Option<&AnyObject>,
) -> c_int
Available on crate features Bluetooth and IOBluetoothRFCOMMChannel only.
pub unsafe fn openRFCOMMChannelSync_withChannelID_delegate( &self, rfcomm_channel: Option<&mut Option<Retained<IOBluetoothRFCOMMChannel>>>, channel_id: BluetoothRFCOMMChannelID, channel_delegate: Option<&AnyObject>, ) -> c_int
Bluetooth and IOBluetoothRFCOMMChannel only.Opens a new RFCOMM channel to the target device. Returns only once the channel is open or failed to open.
This method will begin the process of opening a new RFCOMM channel to the target device. The baseband connection to the device will be opened if it is not open already. The RFCOMM channel open process will not complete until the client has registered an incoming data listener on the new channel. The RFCOMM channel object is already retained when this function returns success; the channel must be released when the caller is done with it.
You should verify that the channel you wish to open exists on the remote device before attempting to open it, by performing an SDP query. This is recommended because the service might have been removed from the, remote device or the channel assignments for the service could have changed (this is rare, but it does happen frequently on some devices). This also works around a bug that existed in early Leopard versions in certain situations where the method would return an error; in these instances, the desired RFCOMM channel could not be opened again until the calling app was restarted.
NOTE: This method is only available in Mac OS X 10.2.5 (Bluetooth v1.2) or later.
Parameter rfcommChannel: A pointer to an IOBluetoothRFCOMMChannel object to receive the RFCOMM channel
requested to be opened. The rfcommChannel pointer will only be set if
kIOReturnSuccess is returned.
Parameter channelID: The RFCOMM channel ID for the new channel.
Parameter channelDelegate: the object that will play the role of delegate for the channel.
A channel delegate is the object the rfcomm uses as target for data and events. The
developer will implement only the the methods he/she is interested in. A list of the
possible methods is at the end of the file “IOBluetoothRFCOMMChannel.h” in the definition
of the protocol IOBluetoothRFCOMMChannelDelegate.
Returns: Returns kIOReturnSuccess if the open process was successfully started (or if an existing RFCOMM channel was found). The channel must be released when the caller is done with it.
Sourcepub unsafe fn openRFCOMMChannelAsync_withChannelID_delegate(
&self,
rfcomm_channel: Option<&mut Option<Retained<IOBluetoothRFCOMMChannel>>>,
channel_id: BluetoothRFCOMMChannelID,
channel_delegate: Option<&AnyObject>,
) -> c_int
Available on crate features Bluetooth and IOBluetoothRFCOMMChannel only.
pub unsafe fn openRFCOMMChannelAsync_withChannelID_delegate( &self, rfcomm_channel: Option<&mut Option<Retained<IOBluetoothRFCOMMChannel>>>, channel_id: BluetoothRFCOMMChannelID, channel_delegate: Option<&AnyObject>, ) -> c_int
Bluetooth and IOBluetoothRFCOMMChannel only.Opens a new RFCOMM channel to the target device. Returns immediately.
This method will begin the process of opening a new RFCOMM channel to the target device. The baseband connection to the device will be opened if it is not open already. The RFCOMM channel open process will not complete until the client has registered an incoming data listener on the new channel. The RFCOMM channel object is already retained when this function returns success; the channel must be released when the caller is done with it.
You should verify that the channel you wish to open exists on the remote device before attempting to open it, by performing an SDP query. This is recommended because the service might have been removed from the, remote device or the channel assignments for the service could have changed (this is rare, but it does happen frequently on some devices). This also works around a bug that existed in early Leopard versions in certain situations where the method would return an error; in these instances, the desired RFCOMM channel could not be opened again until the calling app was restarted.
NOTE: This method is only available in Mac OS X 10.2.5 (Bluetooth v1.2) or later.
Parameter rfcommChannel: A pointer to an IOBluetoothRFCOMMChannel object to receive the RFCOMM channel
requested to be opened. The rfcommChannel pointer will only be set if
kIOReturnSuccess is returned.
Parameter channelID: The RFCOMM channel ID for the new channel.
Parameter channelDelegate: the object that will play the role of delegate for the channel.
A channel delegate is the object the rfcomm uses as target for data and events. The
developer will implement only the the methods he/she is interested in. A list of the
possible methods is at the end of the file “IOBluetoothRFCOMMChannel.h” in the definition
of the protocol IOBluetoothRFCOMMChannelDelegate.
Returns: Returns kIOReturnSuccess if the open process was successfully started (or if an existing RFCOMM channel was found). The channel must be released when the caller is done with it.
Sourcepub unsafe fn classOfDevice(&self) -> BluetoothClassOfDevice
Available on crate feature Bluetooth only.
pub unsafe fn classOfDevice(&self) -> BluetoothClassOfDevice
Bluetooth only.Gets the full class of device value for the remote device.
This value is only meaningful if the target device has been seen during an inquiry. This can be by checking the result of -getLastInquiryUpdate. If nil is returned, then the device hasn’t been seen.
Returns: Returns the class of device for the remote device.
pub unsafe fn getClassOfDevice(&self) -> BluetoothClassOfDevice
Bluetooth only.Sourcepub unsafe fn serviceClassMajor(&self) -> BluetoothServiceClassMajor
Available on crate feature Bluetooth only.
pub unsafe fn serviceClassMajor(&self) -> BluetoothServiceClassMajor
Bluetooth only.Get the major service class of the device.
This value is only meaningful if the target device has been seen during an inquiry. This can be by checking the result of -getLastInquiryUpdate. If nil is returned, then the device hasn’t been seen.
Returns: Returns the major service class of the device.
pub unsafe fn getServiceClassMajor(&self) -> BluetoothServiceClassMajor
Bluetooth only.Sourcepub unsafe fn deviceClassMajor(&self) -> BluetoothDeviceClassMajor
Available on crate feature Bluetooth only.
pub unsafe fn deviceClassMajor(&self) -> BluetoothDeviceClassMajor
Bluetooth only.Get the major device class of the device.
This value is only meaningful if the target device has been seen during an inquiry. This can be by checking the result of -getLastInquiryUpdate. If nil is returned, then the device hasn’t been seen.
Returns: Returns the major device class of the remote device.
pub unsafe fn getDeviceClassMajor(&self) -> BluetoothDeviceClassMajor
Bluetooth only.Sourcepub unsafe fn deviceClassMinor(&self) -> BluetoothDeviceClassMinor
Available on crate feature Bluetooth only.
pub unsafe fn deviceClassMinor(&self) -> BluetoothDeviceClassMinor
Bluetooth only.Get the minor service class of the device.
This value is only meaningful if the target device has been seen during an inquiry. This can be by checking the result of -getLastInquiryUpdate. If nil is returned, then the device hasn’t been seen.
Returns: Returns the minor device class of the remote device.
pub unsafe fn getDeviceClassMinor(&self) -> BluetoothDeviceClassMinor
Bluetooth only.Sourcepub unsafe fn name(&self) -> Retained<NSString>
Available on crate feature objc2-foundation only.
pub unsafe fn name(&self) -> Retained<NSString>
objc2-foundation only.Get the human readable name of the remote device.
This only returns a value if a remote name request has been performed on the target device. If a successful remote name request has not been completed, nil is returned. To perform a remote name request, call -remoteNameRequest. If a remote name request has been successfully completed, the method -getLastNameUpdate will return the date/time of the last successful request.
Returns: Returns the name of the remote device name. This value is an NSString generated from the UTF-8 format of the most recent remote name request.
pub unsafe fn getName(&self) -> Option<Retained<NSString>>
objc2-foundation only.Sourcepub unsafe fn nameOrAddress(&self) -> Option<Retained<NSString>>
Available on crate feature objc2-foundation only.
pub unsafe fn nameOrAddress(&self) -> Option<Retained<NSString>>
objc2-foundation only.Get the human readable name of the remote device. If the name is not present, it will return a string containing the device’s address.
If a remote name request has been successfully completed, the device name will be returned. If not, a string containg the device address in the format of “XX-XX-XX-XX-XX-XX” will be returned.
Returns: Returns the device’s name or a string containing the device’s address.
pub unsafe fn getNameOrAddress(&self) -> Option<Retained<NSString>>
objc2-foundation only.Sourcepub unsafe fn lastNameUpdate(&self) -> Retained<NSDate>
Available on crate feature objc2-foundation only.
pub unsafe fn lastNameUpdate(&self) -> Retained<NSDate>
objc2-foundation only.Get the date/time of the last successful remote name request.
Returns: Returns the date/time of the last successful remote name request. If no remote name request has been completed on the target device, nil is returned.
pub unsafe fn getLastNameUpdate(&self) -> Option<Retained<NSDate>>
objc2-foundation only.Sourcepub unsafe fn getAddress(&self) -> *const BluetoothDeviceAddress
Available on crate feature Bluetooth only.
pub unsafe fn getAddress(&self) -> *const BluetoothDeviceAddress
Bluetooth only.Get the Bluetooth device address for the target device.
Returns: Returns a pointer to the Bluetooth device address of the target device.
Sourcepub unsafe fn addressString(&self) -> Option<Retained<NSString>>
Available on crate feature objc2-foundation only.
pub unsafe fn addressString(&self) -> Option<Retained<NSString>>
objc2-foundation only.Get a string representation of the Bluetooth device address for the target device. The format of the string is the same as returned by IOBluetoothNSStringFromDeviceAddress(void).
NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
Returns: Returns an NSString containing the Bluetooth device address of the target device.
pub unsafe fn getAddressString(&self) -> Option<Retained<NSString>>
objc2-foundation only.Sourcepub unsafe fn getPageScanRepetitionMode(
&self,
) -> BluetoothPageScanRepetitionMode
Available on crate feature Bluetooth only.
pub unsafe fn getPageScanRepetitionMode( &self, ) -> BluetoothPageScanRepetitionMode
Bluetooth only.Get the value of the page scan repetition mode for the device.
This value is only meaningful if the target device has been seen during an inquiry. This can be by checking the result of -getLastInquiryUpdate. If nil is returned, then the device hasn’t been seen.
Returns: Returns the page scan repetition mode value for this device.
Sourcepub unsafe fn getPageScanPeriodMode(&self) -> BluetoothPageScanPeriodMode
Available on crate feature Bluetooth only.
pub unsafe fn getPageScanPeriodMode(&self) -> BluetoothPageScanPeriodMode
Bluetooth only.Get the value of the page scan period mode for the device.
This value is only meaningful if the target device has been seen during an inquiry. This can be by checking the result of -getLastInquiryUpdate. If nil is returned, then the device hasn’t been seen.
Returns: Returns page scan period mode value for the device.
Sourcepub unsafe fn getPageScanMode(&self) -> BluetoothPageScanMode
Available on crate feature Bluetooth only.
pub unsafe fn getPageScanMode(&self) -> BluetoothPageScanMode
Bluetooth only.Get the page scan mode for the device.
This value is only meaningful if the target device has been seen during an inquiry. This can be by checking the result of -getLastInquiryUpdate. If nil is returned, then the device hasn’t been seen.
Returns: Returns the value for the page scan mode for the device.
Sourcepub unsafe fn getClockOffset(&self) -> BluetoothClockOffset
Available on crate feature Bluetooth only.
pub unsafe fn getClockOffset(&self) -> BluetoothClockOffset
Bluetooth only.Get the clock offset value of the device.
This value is only meaningful if the target device has been seen during an inquiry. This can be by checking the result of -getLastInquiryUpdate. If nil is returned, then the device hasn’t been seen.
Returns: Returns the clock offset value for the device.
Sourcepub unsafe fn getLastInquiryUpdate(&self) -> Option<Retained<NSDate>>
Available on crate feature objc2-foundation only.
pub unsafe fn getLastInquiryUpdate(&self) -> Option<Retained<NSDate>>
objc2-foundation only.Get the date/time of the last time the device was returned during an inquiry.
Returns: Returns the date/time of the last time the device was seen during an inquiry. If the device has never been seen during an inquiry, nil is returned.
Sourcepub unsafe fn RSSI(&self) -> BluetoothHCIRSSIValue
Available on crate feature Bluetooth only.
pub unsafe fn RSSI(&self) -> BluetoothHCIRSSIValue
Bluetooth only.Get the RSSI device (if connected), above or below the golden range. If the RSSI is within the golden range, a value of 0 is returned. For the actual RSSI value, use getRawRSSI. For more information, see the Bluetooth 4.0 Core Specification.
Returns: Returns the RSSI of the device. If the value cannot be read (e.g. the device is disconnected), a value of +127 will be returned.
Sourcepub unsafe fn rawRSSI(&self) -> BluetoothHCIRSSIValue
Available on crate feature Bluetooth only.
pub unsafe fn rawRSSI(&self) -> BluetoothHCIRSSIValue
Bluetooth only.Get the raw RSSI device (if connected).
Returns: Returns the raw RSSI of the device.
This value is the perceived RSSI value, not relative the the golden range (see getRSSI for that value). This value will not available on all Bluetooth modules. If the value cannot be read (e.g. the device is disconnected) or is not available on a module, a value of +127 will be returned.
Sourcepub unsafe fn isConnected(&self) -> bool
pub unsafe fn isConnected(&self) -> bool
Indicates whether a baseband connection to the device exists.
Returns: Returns YES if a baseband connection to the device exists.
Sourcepub unsafe fn openConnection(&self) -> c_int
pub unsafe fn openConnection(&self) -> c_int
Create a baseband connection to the device.
This method is synchronous and will not return until either a connection has been established or the create connection has failed (perhaps timed out). This method does the same thing as calling -openConnection: with a nil target. This call with proceed without authentication required, and using the default page timeout value. If authentication or a non-default page timeout is required the method -openConnection:withPageTimeout:authenticationRequired: should be used instead.
As of Mac OS X 10.7, this method will no longer mask out “Connection Exists” ‘errors’ with a success result code; your code must account for the cases where the baseband connection is already open.
Returns: Returns kIOReturnSuccess if the connection was successfully created.
Sourcepub unsafe fn openConnection_(&self, target: Option<&AnyObject>) -> c_int
pub unsafe fn openConnection_(&self, target: Option<&AnyObject>) -> c_int
Create a baseband connection to the device.
If a target is specified, the open connection call is asynchronous and on completion of the CREATE_CONNECTION command, the method -connectionComplete:status: will be called on the specified target. If no target is specified, the call is synchronous and will not return until the connection is open or the CREATE_CONNECTION call has failed. This call with proceed without authentication required, and using the default page timeout value. If authentication or a non-default page timeout is required the method -openConnection:withPageTimeout:authenticationRequired: should be used instead.
As of Mac OS X 10.7, this method will no longer mask out “Connection Exists” ‘errors’ with a success result code; your code must account for the cases where the baseband connection is already open.
Returns: Returns kIOReturnSuccess if the connection was successfully created (or if asynchronous, if the CREATE_CONNECTION command was successfully issued).
Sourcepub unsafe fn openConnection_withPageTimeout_authenticationRequired(
&self,
target: Option<&AnyObject>,
page_timeout_value: BluetoothHCIPageTimeout,
authentication_required: bool,
) -> c_int
Available on crate feature Bluetooth only.
pub unsafe fn openConnection_withPageTimeout_authenticationRequired( &self, target: Option<&AnyObject>, page_timeout_value: BluetoothHCIPageTimeout, authentication_required: bool, ) -> c_int
Bluetooth only.Create a baseband connection to the device.
If a target is specified, the open connection call is asynchronous and on completion of the CREATE_CONNECTION command, the method -connectionComplete:status: will be called on the specified target. If no target is specified, the call is synchronous and will not return until the connection is open or the CREATE_CONNECTION call has failed.
NOTE: This method is only available in Mac OS X 10.2.7 (Bluetooth v1.3) or later.
As of Mac OS X 10.7, this method will no longer mask out “Connection Exists” ‘errors’ with a success result code; your code must account for the cases where the baseband connection is already open.
Parameter target: The target to message when the create connection call is complete
Parameter pageTimeoutValue: The page timeout value to use for this call
Parameter authenticationRequired: BOOL value to indicate whether authentication should be required for the connection
Returns: Returns kIOReturnSuccess if the connection was successfully created (or if asynchronous, if the CREATE_CONNECTION command was successfully issued).
Sourcepub unsafe fn closeConnection(&self) -> c_int
pub unsafe fn closeConnection(&self) -> c_int
Close down the baseband connection to the device.
This method is synchronous and will not return until the connection has been closed (or the command failed). In the future this API will be changed to allow asynchronous operation.
Returns: Returns kIOReturnSuccess if the connection has successfully been closed.
Sourcepub unsafe fn remoteNameRequest(&self, target: Option<&AnyObject>) -> c_int
pub unsafe fn remoteNameRequest(&self, target: Option<&AnyObject>) -> c_int
Issues a remote name request to the target device.
If a target is specified, the request is asynchronous and on completion of the request, the method
- (void)remoteNameRequestComplete:(IOBluetoothDevice *)device status:(IOReturn)status;
will be called on the specified target. If no target is specified, the request is made synchronously and won’t return until the request is complete. This call with operate with the default page timeout value. If a different page timeout value is desired, the method -remoteNameRequest:withPageTimeout: should be used instead.
Parameter target: The target to message when the remote name request is complete
Returns: Returns kIOReturnSuccess if the remote name request was successfully issued (and if synchronous, if the request completed successfully).
Sourcepub unsafe fn remoteNameRequest_withPageTimeout(
&self,
target: Option<&AnyObject>,
page_timeout_value: BluetoothHCIPageTimeout,
) -> c_int
Available on crate feature Bluetooth only.
pub unsafe fn remoteNameRequest_withPageTimeout( &self, target: Option<&AnyObject>, page_timeout_value: BluetoothHCIPageTimeout, ) -> c_int
Bluetooth only.Issues a remote name request to the target device.
If a target is specified, the request is asynchronous and on completion of the REMOTE_NAME_REQUEST command, the method -remoteNameRequestComplete:status:name: will be called on the specified target. If no target is specified, the request is made synchronously and won’t return until the request is complete.
NOTE: This method is only available in Mac OS X 10.2.7 (Bluetooth v1.3) or later.
Parameter target: The target to message when the remote name request is complete
Parameter pageTimeoutValue: The page timeout value to use for this call
Returns: Returns kIOReturnSuccess if the remote name request was successfully issued (and if synchronous, if the request completed successfully).
Sourcepub unsafe fn requestAuthentication(&self) -> c_int
pub unsafe fn requestAuthentication(&self) -> c_int
Requests that the existing baseband connection be authenticated.
In order to authenticate a baseband connection, a link key needs to be generated as a result of the pairing process. This call will synchronously initiate the pairing process with the target device and not return until the authentication process is complete. This API will be updated to allow for asynchronous operation.
Returns: Returns kIOReturnSuccess if the connection has been successfully been authenticated. Returns an error if authentication fails or no baseband connection exists.
Sourcepub unsafe fn connectionHandle(&self) -> BluetoothConnectionHandle
Available on crate feature Bluetooth only.
pub unsafe fn connectionHandle(&self) -> BluetoothConnectionHandle
Bluetooth only.Get the connection handle for the baseband connection.
This method only returns a valid result if a baseband connection is present (-isConnected returns TRUE).
Returns: Returns the connection handle for the baseband connection. If no baseband connection is present, kBluetoothConnectionHandleNone is returned.
pub unsafe fn getConnectionHandle(&self) -> BluetoothConnectionHandle
Bluetooth only.Sourcepub unsafe fn isIncoming(&self) -> bool
pub unsafe fn isIncoming(&self) -> bool
Returns TRUE if the device connection was generated by the remote host.
Returns TRUE if the device connection was generated by the remote host. False if the connection was generated by some other device that connected to the local host.
NOTE: This method is only available in Mac OS X 10.2.7 (Bluetooth v1.3) or later.
Returns: Returns TRUE if the device connection was generated by the remote host.
Sourcepub unsafe fn getLinkType(&self) -> BluetoothLinkType
Available on crate feature Bluetooth only.
pub unsafe fn getLinkType(&self) -> BluetoothLinkType
Bluetooth only.Get the link type for the baseband connection.
This method only returns a valid result if a baseband connection is present (-isConnected returns TRUE).
Returns: Returns the link type for the baseband connection. If no baseband connection is present, kBluetoothLinkTypeNone is returned.
Sourcepub unsafe fn getEncryptionMode(&self) -> BluetoothHCIEncryptionMode
Available on crate feature Bluetooth only.
pub unsafe fn getEncryptionMode(&self) -> BluetoothHCIEncryptionMode
Bluetooth only.Get the encryption mode for the baseband connection.
This method only returns a valid result if a baseband connection is present (-isConnected returns TRUE).
Returns: Returns the encryption mode for the baseband connection. If no baseband connection is present, kEncryptionDisabled is returned.
Sourcepub unsafe fn performSDPQuery(&self, target: Option<&AnyObject>) -> c_int
pub unsafe fn performSDPQuery(&self, target: Option<&AnyObject>) -> c_int
Performs an SDP query on the target device.
As a result of this call, a baseband connection will be built to the device (if not already connected). Then, an L2CAP channel will be opened to the SDP server on the device. At that point, a Service Search Attribute request will be issued with a UUID of 0x0100 (L2CAP) and an attribute range of 0x0000 - 0xffff specified. This will cause the SDP server to return all attributes of all L2CAP-derived services on the device. The results essentially encompass all services on the device. This function is always asynchronous. If a target is specified, when the SDP query is complete (or an error is encountered), the method -sdpQueryComplete:status: will be called on the given target. If no target is specified, the request is still asynchronous, but no callback will be made. That can be useful if the client has registered for SDP service changed notifications.
Parameter target: The target to message when the SDP query is complete
Returns: Returns kIOReturnSuccess if the SDP query was successfully started.
Sourcepub unsafe fn performSDPQuery_uuids(
&self,
target: Option<&AnyObject>,
uuid_array: Option<&NSArray>,
) -> c_int
Available on crate feature objc2-foundation only.
pub unsafe fn performSDPQuery_uuids( &self, target: Option<&AnyObject>, uuid_array: Option<&NSArray>, ) -> c_int
objc2-foundation only.Performs an SDP query on the target device with the specified service UUIDs.
As a result of this call, a baseband connection will be built to the device (if not already connected). Then, an L2CAP channel will be opened to the SDP server on the device. At that point, a Service Search Attribute request will be issued for each service UUID specified in the UUID array.
This function is always asynchronous. If a target is specified, when the SDP query is complete (or an error is encountered), the method -sdpQueryComplete:status: will be called on the given target. If no target is specified, the request is still asynchronous, but no callback will be made. That can be useful if the client has registered for SDP service changed notifications.
Parameter target: The target to message when the SDP query is complete
Parameter uuidArray: An array of IOBluetoothSDPUUID objects for each service the caller is interested in
Returns: Returns kIOReturnSuccess if the SDP query was successfully started.
Sourcepub unsafe fn services(&self) -> Option<Retained<NSArray>>
Available on crate feature objc2-foundation only.
pub unsafe fn services(&self) -> Option<Retained<NSArray>>
objc2-foundation only.Gets an array of service records for the device.
The resulting array contains IOBluetoothSDPServiceRecord objects. The service records are only present if an SDP query has been done on the target object. This can be determined by calling -getLastServicesUpdate. It will return the last date/time of the SDP query. To initiate an SDP query on a device, use -performSDPQuery: as defined above.
Instead of allowing individual clients to query for different services and service attributes, the system request all of the device’s services and service attributes.
Returns: Returns an array of service records for the device if an SDP query has been performed. If no SDP query has been performed, nil is returned.
pub unsafe fn getServices(&self) -> Option<Retained<NSArray>>
objc2-foundation only.Sourcepub unsafe fn getLastServicesUpdate(&self) -> Option<Retained<NSDate>>
Available on crate feature objc2-foundation only.
pub unsafe fn getLastServicesUpdate(&self) -> Option<Retained<NSDate>>
objc2-foundation only.Get the date/time of the last SDP query.
Returns: Returns the date/time of the last SDP query. If an SDP query has never been performed on the device, nil is returned.
Sourcepub unsafe fn getServiceRecordForUUID(
&self,
sdp_uuid: Option<&IOBluetoothSDPUUID>,
) -> Option<Retained<IOBluetoothSDPServiceRecord>>
Available on crate features IOBluetoothSDPServiceRecord and IOBluetoothSDPUUID and objc2-foundation only.
pub unsafe fn getServiceRecordForUUID( &self, sdp_uuid: Option<&IOBluetoothSDPUUID>, ) -> Option<Retained<IOBluetoothSDPServiceRecord>>
IOBluetoothSDPServiceRecord and IOBluetoothSDPUUID and objc2-foundation only.Search for a service record containing the given UUID.
This method searches through the device’s services to find a service that contains the given UUID. Only the first service record will be returned. This method only operates on services that have already been queried. It will not initiate a new query. This method should probably be updated to return an array of service records if more than one contains the UUID.
Parameter sdpUUID: UUID value to search for.
Returns: Returns the first service record that contains the given uuid. If no service record is found, nil is returned.
Sourcepub unsafe fn favoriteDevices() -> Option<Retained<NSArray>>
Available on crate feature objc2-foundation only.
pub unsafe fn favoriteDevices() -> Option<Retained<NSArray>>
objc2-foundation only.Gets an array of the user’s favorite devices.
The resulting array contains IOBluetoothDevice objects.
NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
Returns: Returns an array of device objects representing the user’s favorite devices. If the user has no favorites, nil is returned.
Sourcepub unsafe fn isFavorite(&self) -> bool
pub unsafe fn isFavorite(&self) -> bool
Reports whether the target device is a favorite for the user.
NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
Returns: Returns TRUE if the target device is a favorite for the user, FALSE if not.
Sourcepub unsafe fn addToFavorites(&self) -> c_int
pub unsafe fn addToFavorites(&self) -> c_int
Adds the target device to the user’s favorite devices list.
NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
Returns: Returns kIOReturnSuccess if the device was successfully added to the user’s list of favorite devices.
Sourcepub unsafe fn removeFromFavorites(&self) -> c_int
pub unsafe fn removeFromFavorites(&self) -> c_int
Removes the target device from the user’s favorite devices list.
NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
Returns: Returns kIOReturnSuccess if the device was successfully removed from the user’s list of favorite devices.
Sourcepub unsafe fn recentDevices(num_devices: c_ulong) -> Option<Retained<NSArray>>
Available on crate feature objc2-foundation only.
pub unsafe fn recentDevices(num_devices: c_ulong) -> Option<Retained<NSArray>>
objc2-foundation only.Gets an array of recently used Bluetooth devices.
The resulting array contains IOBluetoothDevice objects sorted in reverse chronological order. The most recently accessed devices are first. If the numDevices parameter is 0, all devices accessed by the system are returned. If numDevices is non-zero, only the most recent devices are returned.
NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
Parameter numDevices: The number of devices to return.
Returns: Returns an array of device objects recently used by the system. If no devices have been accessed, nil is returned.
Sourcepub unsafe fn recentAccessDate(&self) -> Option<Retained<NSDate>>
Available on crate feature objc2-foundation only.
pub unsafe fn recentAccessDate(&self) -> Option<Retained<NSDate>>
objc2-foundation only.Returns the date/time of the most recent access of the target device.
This is the date that -recentDevices uses to sort its list of the most recently accessed devices.
NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
Returns: Returns the date/time of the most recent access of the target device. If the device has not been accessed, nil is returned.
Sourcepub unsafe fn pairedDevices() -> Option<Retained<NSArray>>
Available on crate feature objc2-foundation only.
pub unsafe fn pairedDevices() -> Option<Retained<NSArray>>
objc2-foundation only.Gets an array of all of the paired devices on the system.
The resulting array contains IOBluetoothDevice objects. The paired devices are currently NOT stored per user, so this is all devices paired by any user.
NOTE: This method is only available in Mac OS X 10.2.5 (Bluetooth v1.2) or later.
Returns: Returns an array of device objects for all of the paired devices on the system. If there are no paired devices, nil is returned.
Sourcepub unsafe fn isPaired(&self) -> bool
pub unsafe fn isPaired(&self) -> bool
Returns whether the target device is paired.
NOTE: This method is only available in Mac OS X 10.2.5 (Bluetooth v1.2) or later.
Returns: Returns TRUE if the target device is paired, FALSE if not.
Sourcepub unsafe fn setSupervisionTimeout(&self, timeout: u16) -> c_int
pub unsafe fn setSupervisionTimeout(&self, timeout: u16) -> c_int
Sets the connection supervision timeout.
NOTE: This method is only available in Mac OS X 10.5 (Bluetooth v2.0) or later.
Parameter timeout: A client-supplied link supervision timeout value to use to monitor the connection. The timeout
value should be specified in slots, so you can use the BluetoothGetSlotsFromSeconds macro to get the proper
value. e.g. BluetoothGetSlotsFromSeconds( 5.0 ) will give yield the proper number of slots (8000) for 5 seconds.
Returns: Returns kIOReturnSuccess if it was possible to set the connection supervision timeout.
Sourcepub unsafe fn openL2CAPChannelSync_withPSM_withConfiguration_delegate(
&self,
new_channel: Option<&mut Option<Retained<IOBluetoothL2CAPChannel>>>,
psm: BluetoothL2CAPPSM,
channel_configuration: Option<&NSDictionary>,
channel_delegate: Option<&AnyObject>,
) -> c_int
Available on crate features Bluetooth and IOBluetoothL2CAPChannel and objc2-foundation only.
pub unsafe fn openL2CAPChannelSync_withPSM_withConfiguration_delegate( &self, new_channel: Option<&mut Option<Retained<IOBluetoothL2CAPChannel>>>, psm: BluetoothL2CAPPSM, channel_configuration: Option<&NSDictionary>, channel_delegate: Option<&AnyObject>, ) -> c_int
Bluetooth and IOBluetoothL2CAPChannel and objc2-foundation only.Opens a new L2CAP channel to the target device. Returns only after the channel is opened.
This method will begin the process of opening a new L2CAP channel to the target device. The baseband connection to the device will be opened if it is not open already. The L2CAP channel open process will not complete until the client has registered an incoming data listener on the new channel. This prevents a situation where the channel succeeds in being configured and opened and receives data before the client is listening and is ready for it. The L2CAP channel object is already retained when this function returns success; the channel must be released when the caller is done with it.
NOTE: This method is only available in Mac OS X 10.5 (Bluetooth v2.0) or later.
Parameter newChannel: A pointer to an IOBluetoothL2CAPChannel object to receive the L2CAP channel
requested to be opened. The newChannel pointer will only be set if
kIOReturnSuccess is returned.
Parameter withPSM: The L2CAP PSM value for the new channel.
Parameter channelConfiguration: the dictionary that describes the initial configuration for
the channel.
Parameter channelDelegate: the object that will play the role of delegate for the channel.
A channel delegate is the object the l2cap uses as target for data and events. The
developer will implement only the the methods he/she is interested in. A list of the
possible methods is at the end of the file “IOBluetoothL2CAPChannel.h” in the definition
of the protocol IOBluetoothL2CAPChannelDelegate.
Returns: Returns kIOReturnSuccess if the open process was successfully started (or if an existing L2CAP channel was found). The channel must be released when the caller is done with it.
Sourcepub unsafe fn openL2CAPChannelAsync_withPSM_withConfiguration_delegate(
&self,
new_channel: Option<&mut Option<Retained<IOBluetoothL2CAPChannel>>>,
psm: BluetoothL2CAPPSM,
channel_configuration: Option<&NSDictionary>,
channel_delegate: Option<&AnyObject>,
) -> c_int
Available on crate features Bluetooth and IOBluetoothL2CAPChannel and objc2-foundation only.
pub unsafe fn openL2CAPChannelAsync_withPSM_withConfiguration_delegate( &self, new_channel: Option<&mut Option<Retained<IOBluetoothL2CAPChannel>>>, psm: BluetoothL2CAPPSM, channel_configuration: Option<&NSDictionary>, channel_delegate: Option<&AnyObject>, ) -> c_int
Bluetooth and IOBluetoothL2CAPChannel and objc2-foundation only.Opens a new L2CAP channel to the target device. Returns immediately after starting the opening process.
This method will begin the process of opening a new L2CAP channel to the target device. The baseband connection to the device will be opened if it is not open already. The L2CAP channel open process will not complete until the client has registered an incoming data listener on the new channel. This prevents a situation where the channel succeeds in being configured and opened and receives data before the client is listening and is ready for it. The L2CAP channel object is already retained when this function returns success; the channel must be released when the caller is done with it.
NOTE: This method is only available in Mac OS X 10.5 (Bluetooth v2.0) or later.
Parameter newChannel: A pointer to an IOBluetoothL2CAPChannel object to receive the L2CAP channel
requested to be opened. The newChannel pointer will only be set if
kIOReturnSuccess is returned.
Parameter psm: The L2CAP PSM value for the new channel.
Parameter channelConfiguration: the dictionary that describes the initial configuration for
the channel.
Parameter channelDelegate: the object that will play the role of delegate for the channel.
A channel delegate is the object the l2cap uses as target for data and events. The
developer will implement only the the methods he/she is interested in. A list of the
possible methods is at the end of the file “IOBluetoothL2CAPChannel.h” in the definition
of the protocol IOBluetoothL2CAPChannelDelegate.
Returns: Returns kIOReturnSuccess if the open process was successfully started (or if an existing L2CAP channel was found). The channel must be released when the caller is done with it.
Source§impl IOBluetoothDevice
Methods declared on superclass NSObject.
impl IOBluetoothDevice
Methods declared on superclass NSObject.
Source§impl IOBluetoothDevice
HandsFreeDeviceAdditions.
impl IOBluetoothDevice
HandsFreeDeviceAdditions.
Sourcepub unsafe fn handsFreeAudioGatewayDriverID(&self) -> Option<Retained<NSString>>
👎DeprecatedAvailable on crate features IOBluetoothHandsFree and objc2-foundation only.
pub unsafe fn handsFreeAudioGatewayDriverID(&self) -> Option<Retained<NSString>>
IOBluetoothHandsFree and objc2-foundation only.Return the hands free gateway driver ID
Returns the hands free gateway driver ID which is unique based on BT Address.
Returns: The hands free gateway driver ID
Sourcepub unsafe fn handsFreeAudioGatewayServiceRecord(
&self,
) -> Option<Retained<IOBluetoothSDPServiceRecord>>
Available on crate features IOBluetoothHandsFree and IOBluetoothSDPServiceRecord only.
pub unsafe fn handsFreeAudioGatewayServiceRecord( &self, ) -> Option<Retained<IOBluetoothSDPServiceRecord>>
IOBluetoothHandsFree and IOBluetoothSDPServiceRecord only.Return the hands free gateway SDP record
Returns the hands free gateway SDP record.
Returns: The hands free gateway SDP record
Sourcepub unsafe fn isHandsFreeAudioGateway(&self) -> bool
Available on crate feature IOBluetoothHandsFree only.
pub unsafe fn isHandsFreeAudioGateway(&self) -> bool
IOBluetoothHandsFree only.Return the devices support for hands free gateway
Returns the devices support for hands free gateway (obtained from the devices SDP record).
Returns: YES if the device supports hands free gateway; otherwise, NO.
Sourcepub unsafe fn handsFreeDeviceDriverID(&self) -> Option<Retained<NSString>>
👎DeprecatedAvailable on crate features IOBluetoothHandsFree and objc2-foundation only.
pub unsafe fn handsFreeDeviceDriverID(&self) -> Option<Retained<NSString>>
IOBluetoothHandsFree and objc2-foundation only.Return the hands free device driver ID
Returns the hands free device driver ID which is unique based on BT Address.
Returns: The hands free device driver ID
Sourcepub unsafe fn handsFreeDeviceServiceRecord(
&self,
) -> Option<Retained<IOBluetoothSDPServiceRecord>>
Available on crate features IOBluetoothHandsFree and IOBluetoothSDPServiceRecord only.
pub unsafe fn handsFreeDeviceServiceRecord( &self, ) -> Option<Retained<IOBluetoothSDPServiceRecord>>
IOBluetoothHandsFree and IOBluetoothSDPServiceRecord only.Return the hands free device SDP record
Returns the hands free device SDP record.
Returns: The hands free device SDP record
Sourcepub unsafe fn isHandsFreeDevice(&self) -> bool
Available on crate feature IOBluetoothHandsFree only.
pub unsafe fn isHandsFreeDevice(&self) -> bool
IOBluetoothHandsFree only.Return the devices support for hands free device
Returns the devices support for hands free device (obtained from the devices SDP record).
Returns: YES if the device supports hands free device; otherwise, NO.
Methods from Deref<Target = NSObject>§
Sourcepub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
pub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
Handle messages the object doesn’t recognize.
See Apple’s documentation for details.
Methods from Deref<Target = AnyObject>§
Sourcepub fn class(&self) -> &'static AnyClass
pub fn class(&self) -> &'static AnyClass
Dynamically find the class of this object.
§Panics
May panic if the object is invalid (which may be the case for objects
returned from unavailable init/new methods).
§Example
Check that an instance of NSObject has the precise class NSObject.
use objc2::ClassType;
use objc2::runtime::NSObject;
let obj = NSObject::new();
assert_eq!(obj.class(), NSObject::class());Sourcepub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
👎Deprecated: this is difficult to use correctly, use Ivar::load instead.
pub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
Ivar::load instead.Use Ivar::load instead.
§Safety
The object must have an instance variable with the given name, and it
must be of type T.
See Ivar::load_ptr for details surrounding this.
Sourcepub fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastTarget,
pub fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastTarget,
Attempt to downcast the object to a class of type T.
This is the reference-variant. Use Retained::downcast if you want
to convert a retained object to another type.
§Mutable classes
Some classes have immutable and mutable variants, such as NSString
and NSMutableString.
When some Objective-C API signature says it gives you an immutable class, it generally expects you to not mutate that, even though it may technically be mutable “under the hood”.
So using this method to convert a NSString to a NSMutableString,
while not unsound, is generally frowned upon unless you created the
string yourself, or the API explicitly documents the string to be
mutable.
See Apple’s documentation on mutability and on
isKindOfClass: for more details.
§Generic classes
Objective-C generics are called “lightweight generics”, and that’s because they aren’t exposed in the runtime. This makes it impossible to safely downcast to generic collections, so this is disallowed by this method.
You can, however, safely downcast to generic collections where all the
type-parameters are AnyObject.
§Panics
This works internally by calling isKindOfClass:. That means that the
object must have the instance method of that name, and an exception
will be thrown (if CoreFoundation is linked) or the process will abort
if that is not the case. In the vast majority of cases, you don’t need
to worry about this, since both root objects NSObject and
NSProxy implement this method.
§Examples
Cast an NSString back and forth from NSObject.
use objc2::rc::Retained;
use objc2_foundation::{NSObject, NSString};
let obj: Retained<NSObject> = NSString::new().into_super();
let string = obj.downcast_ref::<NSString>().unwrap();
// Or with `downcast`, if we do not need the object afterwards
let string = obj.downcast::<NSString>().unwrap();Try (and fail) to cast an NSObject to an NSString.
use objc2_foundation::{NSObject, NSString};
let obj = NSObject::new();
assert!(obj.downcast_ref::<NSString>().is_none());Try to cast to an array of strings.
use objc2_foundation::{NSArray, NSObject, NSString};
let arr = NSArray::from_retained_slice(&[NSObject::new()]);
// This is invalid and doesn't type check.
let arr = arr.downcast_ref::<NSArray<NSString>>();This fails to compile, since it would require enumerating over the array to ensure that each element is of the desired type, which is a performance pitfall.
Downcast when processing each element instead.
use objc2_foundation::{NSArray, NSObject, NSString};
let arr = NSArray::from_retained_slice(&[NSObject::new()]);
for elem in arr {
if let Some(data) = elem.downcast_ref::<NSString>() {
// handle `data`
}
}Trait Implementations§
Source§impl AsRef<AnyObject> for IOBluetoothDevice
impl AsRef<AnyObject> for IOBluetoothDevice
Source§impl AsRef<IOBluetoothDevice> for IOBluetoothDevice
impl AsRef<IOBluetoothDevice> for IOBluetoothDevice
Source§impl AsRef<IOBluetoothObject> for IOBluetoothDevice
impl AsRef<IOBluetoothObject> for IOBluetoothDevice
Source§fn as_ref(&self) -> &IOBluetoothObject
fn as_ref(&self) -> &IOBluetoothObject
Source§impl AsRef<NSObject> for IOBluetoothDevice
impl AsRef<NSObject> for IOBluetoothDevice
Source§impl Borrow<AnyObject> for IOBluetoothDevice
impl Borrow<AnyObject> for IOBluetoothDevice
Source§impl Borrow<IOBluetoothObject> for IOBluetoothDevice
impl Borrow<IOBluetoothObject> for IOBluetoothDevice
Source§fn borrow(&self) -> &IOBluetoothObject
fn borrow(&self) -> &IOBluetoothObject
Source§impl Borrow<NSObject> for IOBluetoothDevice
impl Borrow<NSObject> for IOBluetoothDevice
Source§impl ClassType for IOBluetoothDevice
impl ClassType for IOBluetoothDevice
Source§const NAME: &'static str = "IOBluetoothDevice"
const NAME: &'static str = "IOBluetoothDevice"
Source§type Super = IOBluetoothObject
type Super = IOBluetoothObject
Source§type ThreadKind = <<IOBluetoothDevice as ClassType>::Super as ClassType>::ThreadKind
type ThreadKind = <<IOBluetoothDevice as ClassType>::Super as ClassType>::ThreadKind
Source§impl CopyingHelper for IOBluetoothDevice
Available on crate feature objc2-foundation only.
impl CopyingHelper for IOBluetoothDevice
objc2-foundation only.Source§type Result = IOBluetoothDevice
type Result = IOBluetoothDevice
Self if the type has no
immutable counterpart. Read moreSource§impl Debug for IOBluetoothDevice
impl Debug for IOBluetoothDevice
Source§impl Deref for IOBluetoothDevice
impl Deref for IOBluetoothDevice
Source§impl Hash for IOBluetoothDevice
impl Hash for IOBluetoothDevice
Source§impl Message for IOBluetoothDevice
impl Message for IOBluetoothDevice
Source§impl NSCopying for IOBluetoothDevice
impl NSCopying for IOBluetoothDevice
Source§impl NSObjectProtocol for IOBluetoothDevice
impl NSObjectProtocol for IOBluetoothDevice
Source§fn isEqual(&self, other: Option<&AnyObject>) -> bool
fn isEqual(&self, other: Option<&AnyObject>) -> bool
Source§fn hash(&self) -> usize
fn hash(&self) -> usize
Source§fn isKindOfClass(&self, cls: &AnyClass) -> bool
fn isKindOfClass(&self, cls: &AnyClass) -> bool
Source§fn is_kind_of<T>(&self) -> bool
fn is_kind_of<T>(&self) -> bool
isKindOfClass directly, or cast your objects with AnyObject::downcast_ref