pub struct DDDevice { /* private fields */ }DDDevice only.Expand description
DeviceDiscoveryExtension device.
See also Apple’s documentation
Implementations§
Source§impl DDDevice
impl DDDevice
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>
Sourcepub unsafe fn initWithDisplayName_category_protocolType_identifier(
this: Allocated<Self>,
display_name: &NSString,
category: DDDeviceCategory,
protocol_type: &UTType,
identifier: &NSString,
) -> Retained<Self>
Available on crate feature objc2-uniform-type-identifiers only.
pub unsafe fn initWithDisplayName_category_protocolType_identifier( this: Allocated<Self>, display_name: &NSString, category: DDDeviceCategory, protocol_type: &UTType, identifier: &NSString, ) -> Retained<Self>
objc2-uniform-type-identifiers only.Initializes a DD device with display name, category, protocol type, and identifier.
Sourcepub unsafe fn deviceSupports(&self) -> DDDeviceSupports
pub unsafe fn deviceSupports(&self) -> DDDeviceSupports
Device supported capabilities.
Sourcepub unsafe fn setDeviceSupports(&self, device_supports: DDDeviceSupports)
pub unsafe fn setDeviceSupports(&self, device_supports: DDDeviceSupports)
Setter for deviceSupports.
Sourcepub unsafe fn bluetoothIdentifier(&self) -> Option<Retained<NSUUID>>
pub unsafe fn bluetoothIdentifier(&self) -> Option<Retained<NSUUID>>
Identifier to communicate with the device via Bluetooth.
Sourcepub unsafe fn setBluetoothIdentifier(
&self,
bluetooth_identifier: Option<&NSUUID>,
)
pub unsafe fn setBluetoothIdentifier( &self, bluetooth_identifier: Option<&NSUUID>, )
Setter for bluetoothIdentifier.
Sourcepub unsafe fn category(&self) -> DDDeviceCategory
pub unsafe fn category(&self) -> DDDeviceCategory
Category of the device.
Sourcepub unsafe fn setCategory(&self, category: DDDeviceCategory)
pub unsafe fn setCategory(&self, category: DDDeviceCategory)
Setter for category.
Sourcepub unsafe fn displayImageName(&self) -> Option<Retained<NSString>>
pub unsafe fn displayImageName(&self) -> Option<Retained<NSString>>
Device’s custom asset for product image name in the main App bundle.
Sourcepub unsafe fn setDisplayImageName(&self, display_image_name: Option<&NSString>)
pub unsafe fn setDisplayImageName(&self, display_image_name: Option<&NSString>)
Setter for displayImageName.
This is copied when set.
Sourcepub unsafe fn displayName(&self) -> Retained<NSString>
pub unsafe fn displayName(&self) -> Retained<NSString>
Name of the device. Should be suitable for displaying to a user.
Sourcepub unsafe fn setDisplayName(&self, display_name: &NSString)
pub unsafe fn setDisplayName(&self, display_name: &NSString)
Setter for displayName.
This is copied when set.
Sourcepub unsafe fn identifier(&self) -> Retained<NSString>
pub unsafe fn identifier(&self) -> Retained<NSString>
Identifier of the device.
Sourcepub unsafe fn setIdentifier(&self, identifier: &NSString)
pub unsafe fn setIdentifier(&self, identifier: &NSString)
Setter for identifier.
This is copied when set.
Sourcepub unsafe fn mediaPlaybackState(&self) -> DDDeviceMediaPlaybackState
pub unsafe fn mediaPlaybackState(&self) -> DDDeviceMediaPlaybackState
Current state of media playback on this device.
Sourcepub unsafe fn setMediaPlaybackState(
&self,
media_playback_state: DDDeviceMediaPlaybackState,
)
pub unsafe fn setMediaPlaybackState( &self, media_playback_state: DDDeviceMediaPlaybackState, )
Setter for mediaPlaybackState.
Sourcepub unsafe fn mediaContentTitle(&self) -> Option<Retained<NSString>>
pub unsafe fn mediaContentTitle(&self) -> Option<Retained<NSString>>
Title of the media content being played.
Sourcepub unsafe fn setMediaContentTitle(
&self,
media_content_title: Option<&NSString>,
)
pub unsafe fn setMediaContentTitle( &self, media_content_title: Option<&NSString>, )
Setter for mediaContentTitle.
This is copied when set.
Sourcepub unsafe fn mediaContentSubtitle(&self) -> Option<Retained<NSString>>
pub unsafe fn mediaContentSubtitle(&self) -> Option<Retained<NSString>>
Subtitle of the media content being played. It can be used to display extra information about the content, such as the name of the artist.
Sourcepub unsafe fn setMediaContentSubtitle(
&self,
media_content_subtitle: Option<&NSString>,
)
pub unsafe fn setMediaContentSubtitle( &self, media_content_subtitle: Option<&NSString>, )
Setter for mediaContentSubtitle.
This is copied when set.
Sourcepub unsafe fn protocol(&self) -> DDDeviceProtocol
pub unsafe fn protocol(&self) -> DDDeviceProtocol
Protocol of the device.
Sourcepub unsafe fn setProtocol(&self, protocol: DDDeviceProtocol)
pub unsafe fn setProtocol(&self, protocol: DDDeviceProtocol)
Setter for protocol.
Sourcepub unsafe fn protocolType(&self) -> Retained<UTType>
Available on crate feature objc2-uniform-type-identifiers only.
pub unsafe fn protocolType(&self) -> Retained<UTType>
objc2-uniform-type-identifiers only.Uniform Type for the protocol.
Sourcepub unsafe fn setProtocolType(&self, protocol_type: &UTType)
Available on crate feature objc2-uniform-type-identifiers only.
pub unsafe fn setProtocolType(&self, protocol_type: &UTType)
objc2-uniform-type-identifiers only.Setter for protocolType.
Sourcepub unsafe fn state(&self) -> DDDeviceState
pub unsafe fn state(&self) -> DDDeviceState
State of the device.
Sourcepub unsafe fn setState(&self, state: DDDeviceState)
pub unsafe fn setState(&self, state: DDDeviceState)
Setter for state.
Sourcepub unsafe fn supportsGrouping(&self) -> bool
pub unsafe fn supportsGrouping(&self) -> bool
Whether the device supports grouping with other devices with the same protocol.
Sourcepub unsafe fn setSupportsGrouping(&self, supports_grouping: bool)
pub unsafe fn setSupportsGrouping(&self, supports_grouping: bool)
Setter for supportsGrouping.
Sourcepub unsafe fn txtRecordData(&self) -> Option<Retained<NSData>>
pub unsafe fn txtRecordData(&self) -> Option<Retained<NSData>>
TXT record of the device.
Sourcepub unsafe fn setTxtRecordData(&self, txt_record_data: Option<&NSData>)
pub unsafe fn setTxtRecordData(&self, txt_record_data: Option<&NSData>)
Setter for txtRecordData.
This is copied when set.
Sourcepub unsafe fn url(&self) -> Retained<NSURL>
pub unsafe fn url(&self) -> Retained<NSURL>
URL used for SSDP connection. The URL must have a valid hostname, no query parameters, and a maximum size of 100 bytes.
Sourcepub unsafe fn wifiAwareServiceName(&self) -> Option<Retained<NSString>>
pub unsafe fn wifiAwareServiceName(&self) -> Option<Retained<NSString>>
Device’s Wi-Fi Aware’s service name.
Sourcepub unsafe fn setWifiAwareServiceName(
&self,
wifi_aware_service_name: Option<&NSString>,
)
pub unsafe fn setWifiAwareServiceName( &self, wifi_aware_service_name: Option<&NSString>, )
Setter for wifiAwareServiceName.
This is copied when set.
Sourcepub unsafe fn wifiAwareServiceRole(&self) -> DDDeviceWiFiAwareServiceRole
pub unsafe fn wifiAwareServiceRole(&self) -> DDDeviceWiFiAwareServiceRole
Device’s Wi-Fi Aware’s service. Default is DDDeviceWiFiAwareServiceRoleSubscriber
Sourcepub unsafe fn setWifiAwareServiceRole(
&self,
wifi_aware_service_role: DDDeviceWiFiAwareServiceRole,
)
pub unsafe fn setWifiAwareServiceRole( &self, wifi_aware_service_role: DDDeviceWiFiAwareServiceRole, )
Setter for wifiAwareServiceRole.
Sourcepub unsafe fn wifiAwareModelName(&self) -> Option<Retained<NSString>>
pub unsafe fn wifiAwareModelName(&self) -> Option<Retained<NSString>>
Device’s Wi-Fi Aware model name.
Sourcepub unsafe fn setWifiAwareModelName(
&self,
wifi_aware_model_name: Option<&NSString>,
)
pub unsafe fn setWifiAwareModelName( &self, wifi_aware_model_name: Option<&NSString>, )
Setter for wifiAwareModelName.
This is copied when set.
Sourcepub unsafe fn wifiAwareVendorName(&self) -> Option<Retained<NSString>>
pub unsafe fn wifiAwareVendorName(&self) -> Option<Retained<NSString>>
Device’s Wi-Fi Aware vendor name.
Sourcepub unsafe fn setWifiAwareVendorName(
&self,
wifi_aware_vendor_name: Option<&NSString>,
)
pub unsafe fn setWifiAwareVendorName( &self, wifi_aware_vendor_name: Option<&NSString>, )
Setter for wifiAwareVendorName.
This is copied when set.
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 ClassType for DDDevice
impl ClassType for DDDevice
Source§const NAME: &'static str = "DDDevice"
const NAME: &'static str = "DDDevice"
Source§type ThreadKind = <<DDDevice as ClassType>::Super as ClassType>::ThreadKind
type ThreadKind = <<DDDevice as ClassType>::Super as ClassType>::ThreadKind
Source§impl NSObjectProtocol for DDDevice
impl NSObjectProtocol for DDDevice
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