#[repr(C)]pub struct ICCameraDevice { /* private fields */ }
ICCameraDevice
and ICDevice
only.Expand description
ICCameraDevice is a concrete subclass of ICDevice class. ICDeviceBrowser creates instances of this class.
See also Apple’s documentation
Implementations§
Source§impl ICCameraDevice
impl ICCameraDevice
Sourcepub unsafe fn contentCatalogPercentCompleted(&self) -> NSUInteger
pub unsafe fn contentCatalogPercentCompleted(&self) -> NSUInteger
Indicates the percentage of content cataloging completed on the device. Its value ranges from 0 to 100.
Sourcepub unsafe fn contents(&self) -> Option<Retained<NSArray<ICCameraItem>>>
Available on crate feature ICCameraItem
only.
pub unsafe fn contents(&self) -> Option<Retained<NSArray<ICCameraItem>>>
ICCameraItem
only.Contents of the camera. The structure of the elements in this array will reflect the folder structure of the storage reported by the camera. Each item in this array will correspond to a storage on the camera.
Sourcepub unsafe fn mediaFiles(&self) -> Option<Retained<NSArray<ICCameraItem>>>
Available on crate feature ICCameraItem
only.
pub unsafe fn mediaFiles(&self) -> Option<Retained<NSArray<ICCameraItem>>>
ICCameraItem
only.The property mediaFiles represents all image, movie and audio files on the camera. These files are returned as a single array without regard to the folder hierarchy used to store these files on the camera.
Sourcepub unsafe fn isEjectable(&self) -> bool
pub unsafe fn isEjectable(&self) -> bool
Indicates whether the device can be ‘soft’ removed or disconnected.
Sourcepub unsafe fn isLocked(&self) -> bool
pub unsafe fn isLocked(&self) -> bool
Indicates whether the device is locked. A locked device does not allow for deletion of any asset.
Sourcepub unsafe fn isAccessRestrictedAppleDevice(&self) -> bool
pub unsafe fn isAccessRestrictedAppleDevice(&self) -> bool
Set to YES if the device is made by Apple and is pass-coded locked and connected to an untrusted host.
Sourcepub unsafe fn iCloudPhotosEnabled(&self) -> bool
pub unsafe fn iCloudPhotosEnabled(&self) -> bool
Set to YES if the device is made by Apple and is pass-coded locked and connected to an untrusted host.
Sourcepub unsafe fn mountPoint(&self) -> Option<Retained<NSString>>
pub unsafe fn mountPoint(&self) -> Option<Retained<NSString>>
Filesystem mount point for a device with transportType of ICTransportTypeMassStorage. This will be NULL for all other devices.
Sourcepub unsafe fn mediaPresentation(&self) -> ICMediaPresentation
pub unsafe fn mediaPresentation(&self) -> ICMediaPresentation
The media presentation describes the visible assets from a device that may contain multiple formats of each media asset. The asigngments are of the type ICMediaPresentation enumeration. This property is available only if the capability ICCameraDeviceSupportsHEIF is present.
A device supporting this capability can specify the following presentations:
ICMediaPresentationConverted - The default behavior for applications retrieving images from a device supporting HEIF is to show only converted JPG from HEIF originals, and only H264 encoded video assets from HEVC. ICMediaPresentationOriginal - This presentation will show only original images from a device supporting HEIF and HEVC. Burned in renders are always exported in JPG, as are burned in effects for MOV clips.
Sourcepub unsafe fn setMediaPresentation(
&self,
media_presentation: ICMediaPresentation,
)
pub unsafe fn setMediaPresentation( &self, media_presentation: ICMediaPresentation, )
Setter for mediaPresentation
.
Sourcepub unsafe fn filesOfType(
&self,
file_ut_type: &NSString,
) -> Option<Retained<NSArray<NSString>>>
pub unsafe fn filesOfType( &self, file_ut_type: &NSString, ) -> Option<Retained<NSArray<NSString>>>
This method returns an array of files on the camera of type fileType.
The fileType string is one of the following Uniform Type Identifier strings: kUTTypeImage, kUTTypeMovie, kUTTypeAudio, or kUTTypeData.
Sourcepub unsafe fn requestReadDataFromFile_atOffset_length_readDelegate_didReadDataSelector_contextInfo(
&self,
file: &ICCameraFile,
offset: off_t,
length: off_t,
read_delegate: &AnyObject,
selector: Sel,
context_info: *mut c_void,
)
Available on crate features ICCameraFile
and ICCameraItem
and libc
only.
pub unsafe fn requestReadDataFromFile_atOffset_length_readDelegate_didReadDataSelector_contextInfo( &self, file: &ICCameraFile, offset: off_t, length: off_t, read_delegate: &AnyObject, selector: Sel, context_info: *mut c_void, )
ICCameraFile
and ICCameraItem
and libc
only.This method asynchronously reads data of a specified length from a specified offset.
The readDelegate passed must not be nil. When this request is completed, the didReadDataSelector of the readDelegate object is called. The didReadDataSelector should have the same signature as: - (void)didReadData:(NSData*)data fromFile:(ICCameraFile*)file error:(NSError*)error contextInfo:(void*)contextInfo. The content of error returned should be examined to determine if the request completed successfully.
Sourcepub unsafe fn requestDownloadFile_options_downloadDelegate_didDownloadSelector_contextInfo(
&self,
file: &ICCameraFile,
options: &NSDictionary<ICDownloadOption, AnyObject>,
download_delegate: &ProtocolObject<dyn ICCameraDeviceDownloadDelegate>,
selector: Sel,
context_info: *mut c_void,
)
Available on crate features ICCameraFile
and ICCameraItem
only.
pub unsafe fn requestDownloadFile_options_downloadDelegate_didDownloadSelector_contextInfo( &self, file: &ICCameraFile, options: &NSDictionary<ICDownloadOption, AnyObject>, download_delegate: &ProtocolObject<dyn ICCameraDeviceDownloadDelegate>, selector: Sel, context_info: *mut c_void, )
ICCameraFile
and ICCameraItem
only.Download a file from the camera. Please refer to the top of this header for information about the options.
The downloadDelegate passed must not be nil. When this request is completed, the didDownloadSelector of the downloadDelegate object is called.The didDownloadSelector should have the same signature as: - (void)didDownloadFile:(ICCameraFile*)file error:(NSError*)error options:(NSDictionary*)options contextInfo:(void*)contextInfo. The content of error returned should be examined to determine if the request completed successfully.
Sourcepub unsafe fn cancelDownload(&self)
pub unsafe fn cancelDownload(&self)
Cancels the current download operation if supported
Sourcepub unsafe fn requestDeleteFiles(&self, files: &NSArray<ICCameraItem>)
Available on crate feature ICCameraItem
only.
pub unsafe fn requestDeleteFiles(&self, files: &NSArray<ICCameraItem>)
ICCameraItem
only.Deletes files.
Sourcepub unsafe fn requestDeleteFiles_deleteFailed_completion(
&self,
files: &NSArray<ICCameraItem>,
delete_failed: &DynBlock<dyn Fn(NonNull<NSDictionary<ICDeleteError, ICCameraItem>>)>,
completion: &DynBlock<dyn Fn(NonNull<NSDictionary<ICDeleteResult, NSArray<ICCameraItem>>>, *mut NSError)>,
) -> Option<Retained<NSProgress>>
Available on crate features ICCameraItem
and block2
only.
pub unsafe fn requestDeleteFiles_deleteFailed_completion( &self, files: &NSArray<ICCameraItem>, delete_failed: &DynBlock<dyn Fn(NonNull<NSDictionary<ICDeleteError, ICCameraItem>>)>, completion: &DynBlock<dyn Fn(NonNull<NSDictionary<ICDeleteResult, NSArray<ICCameraItem>>>, *mut NSError)>, ) -> Option<Retained<NSProgress>>
ICCameraItem
and block2
only.Allows for deletion of an array of ICCameraItem objects, with the added ability to catch delete failures using the ‘deleteFailed’ block, and a completion block that will return the overall state of the request.
The deleteFailed block will return:
- NSDictionary <ICDeleteError , ICCameraItem*>*
The completion block will return: — error:
-
nil if successful
-
NSError* with an code set to ICReturnDeleteFilesFailed if any file failed.
-
result: NSDictionary <ICDeleteResult , NSArray <ICCameraItem >>* result
-
ICDeleteSuccessful: NSArray <ICCameraItem > success
-
ICDeleteFailed: NSArray <ICCameraItem > failed
Sourcepub unsafe fn cancelDelete(&self)
pub unsafe fn cancelDelete(&self)
Cancels the current delete operation started by sending a ‘requestDeleteFiles:’. This will only cancel operations in flight when a batch of files have been requested for deletion.
Sourcepub unsafe fn requestSyncClock(&self)
pub unsafe fn requestSyncClock(&self)
Synchronize camera’s clock with the computer’s clock. You should send this request only if the camera has the ‘ICCameraDeviceCanSyncClock’ capability.
Sourcepub unsafe fn timeOffset(&self) -> NSTimeInterval
pub unsafe fn timeOffset(&self) -> NSTimeInterval
Indicates the time offset, in seconds, between the camera’s clock and the computer’s clock. This value is positive if the camera’s clock is ahead of the computer’s clock. This property should be ignored if the camera’s capabilities property does not contain ICCameraDeviceCanSyncClock.
Sourcepub unsafe fn batteryLevelAvailable(&self) -> bool
pub unsafe fn batteryLevelAvailable(&self) -> bool
Indicates if the device has reported battery charge level.
Sourcepub unsafe fn batteryLevel(&self) -> NSUInteger
pub unsafe fn batteryLevel(&self) -> NSUInteger
Indicates the battery charge level. Its value ranges from 0 to 100.
Sourcepub unsafe fn requestUploadFile_options_uploadDelegate_didUploadSelector_contextInfo(
&self,
file_url: &NSURL,
options: &NSDictionary<ICUploadOption, AnyObject>,
upload_delegate: &AnyObject,
selector: Sel,
context_info: *mut c_void,
)
👎Deprecated: Sandbox restrictions prohibit writing directly to device hardware
pub unsafe fn requestUploadFile_options_uploadDelegate_didUploadSelector_contextInfo( &self, file_url: &NSURL, options: &NSDictionary<ICUploadOption, AnyObject>, upload_delegate: &AnyObject, selector: Sel, context_info: *mut c_void, )
Upload a file at fileURL to the camera. The options dictionary is not used in this version.
The uploadDelegate passed must not be nil. When this request is completed, the didUploadSelector of the uploadDelegate object is called. The didUploadSelector should have the same signature as: - (void)didUploadFile:(NSURL*)fileURL error:(NSError*)error contextInfo:(void*)contextInfo. The content of error returned should be examined to determine if the request completed successfully.
Sourcepub unsafe fn tetheredCaptureEnabled(&self) -> bool
pub unsafe fn tetheredCaptureEnabled(&self) -> bool
This property is always set to YES when the device has the capability ‘ICCameraDeviceCanTakePicture’
requestEnableTethering/requestDisableTethering is no longer required to setup and destroy the standard take picture functionality of supported cameras.
Sourcepub unsafe fn requestTakePicture(&self)
pub unsafe fn requestTakePicture(&self)
Capture a new image using the camera, the camera capabilities include ‘ICCameraDeviceCanTakePicture’.
Sourcepub unsafe fn requestEnableTethering(&self)
👎Deprecated: Third party cameras that support the standard take picture command will have the capability enabled by default. This call will have no effect
pub unsafe fn requestEnableTethering(&self)
Send this message to enable tethered capture on the camera device if the camera has the ‘ICCameraDeviceCanTakePicture’ capability.
Sourcepub unsafe fn requestDisableTethering(&self)
👎Deprecated: Third party cameras that support the standard take picture command will have the capability enabled by default. This call will have no effect
pub unsafe fn requestDisableTethering(&self)
Send this message to disable tethered capture on the camera device if the camera has the ‘ICCameraDeviceCanTakePicture’ capability and if your process has already sent a ‘requestEnableTethering’ to it.
Sourcepub unsafe fn ptpEventHandler(
&self,
) -> NonNull<DynBlock<dyn Fn(NonNull<NSData>)>>
Available on crate feature block2
only.
pub unsafe fn ptpEventHandler( &self, ) -> NonNull<DynBlock<dyn Fn(NonNull<NSData>)>>
block2
only.As an alternative to setting up an object to handle PTP event packets, a handler can be set. The handler will always be called in place of the delegate if non-nil. If the handler is not present, the delegate will be called if present. It is guaranteed only one of the methods will be called if both are implemented.
Sourcepub unsafe fn setPtpEventHandler(
&self,
ptp_event_handler: &DynBlock<dyn Fn(NonNull<NSData>)>,
)
Available on crate feature block2
only.
pub unsafe fn setPtpEventHandler( &self, ptp_event_handler: &DynBlock<dyn Fn(NonNull<NSData>)>, )
block2
only.Setter for ptpEventHandler
.
Sourcepub unsafe fn requestSendPTPCommand_outData_sendCommandDelegate_didSendCommandSelector_contextInfo(
&self,
command: &NSData,
data: Option<&NSData>,
send_command_delegate: &AnyObject,
selector: Sel,
context_info: *mut c_void,
)
pub unsafe fn requestSendPTPCommand_outData_sendCommandDelegate_didSendCommandSelector_contextInfo( &self, command: &NSData, data: Option<&NSData>, send_command_delegate: &AnyObject, selector: Sel, context_info: *mut c_void, )
This method asynchronously sends a PTP command to a camera.
This should be sent only if the ‘capabilities’ property contains ‘ICCameraDeviceCanAcceptPTPCommands’. All PTP cameras have this capability. The response to this command will be delivered using didSendCommandSelector of sendCommandDelegate. The didSendCommandSelector should have the same signature as: - (void)didSendPTPCommand:(NSData*)command inData:(NSData*)data response:(NSData*)response error:(NSError*)error contextInfo:(void*)contextInfo. The content of error returned should be examined to determine if the request completed successfully.
Sourcepub unsafe fn requestSendPTPCommand_outData_completion(
&self,
ptp_command: &NSData,
ptp_data: Option<&NSData>,
completion: &DynBlock<dyn Fn(NonNull<NSData>, NonNull<NSData>, *mut NSError)>,
)
Available on crate feature block2
only.
pub unsafe fn requestSendPTPCommand_outData_completion( &self, ptp_command: &NSData, ptp_data: Option<&NSData>, completion: &DynBlock<dyn Fn(NonNull<NSData>, NonNull<NSData>, *mut NSError)>, )
block2
only.This method asynchronously sends a PTP command to a camera.
The response, data, and any error message will be returned the block.
Methods from Deref<Target = ICDevice>§
Sourcepub unsafe fn delegate(
&self,
) -> Option<Retained<ProtocolObject<dyn ICDeviceDelegate>>>
pub unsafe fn delegate( &self, ) -> Option<Retained<ProtocolObject<dyn ICDeviceDelegate>>>
The delegate to receive messages once a session is opened on the device.
The delegate must conform ICDeviceDelegate protocol. In addition it should respond to selectors defined in ICCameraDeviceDelegate protocol in order to effectively interact with the device object. The messages this delegate can expect to receive are described by these protocols.
Sourcepub unsafe fn setDelegate(
&self,
delegate: Option<&ProtocolObject<dyn ICDeviceDelegate>>,
)
pub unsafe fn setDelegate( &self, delegate: Option<&ProtocolObject<dyn ICDeviceDelegate>>, )
Setter for delegate
.
Sourcepub unsafe fn type(&self) -> ICDeviceType
pub unsafe fn type(&self) -> ICDeviceType
The type of the device as defined by ICDeviceType OR’d with its ICDeviceLocationType.
Note: The type of this device can be obtained by AND’ing the value retuned by this property with an appropriate ICDeviceTypeMask.
Note: The location type of this device can be obtained by AND’ing the value retuned by this property with an appropriate ICDeviceLocationTypeMask.
Sourcepub unsafe fn capabilities(&self) -> Retained<NSArray<NSString>>
pub unsafe fn capabilities(&self) -> Retained<NSArray<NSString>>
The capabilities of the device as reported by the device module.
Sourcepub unsafe fn name(&self) -> Option<Retained<NSString>>
pub unsafe fn name(&self) -> Option<Retained<NSString>>
Name of the device as reported by the device module or by the device transport when a device module is not in control of this device.
Note: This name may change if the device module overrides the default name of the device reported by the device’s transport, or if the name of the filesystem volume mounted by the device is changed by the user.
Sourcepub unsafe fn productKind(&self) -> Option<Retained<NSString>>
pub unsafe fn productKind(&self) -> Option<Retained<NSString>>
Type of the device. Possible values are: “ iPhone“, @“iPod”, @“iPad”, @“Camera”, @“Scanner”
Sourcepub unsafe fn icon(&self) -> Option<Retained<CGImage>>
Available on crate feature objc2-core-graphics
only.
pub unsafe fn icon(&self) -> Option<Retained<CGImage>>
objc2-core-graphics
only.Icon image for the device class. If there is no custom icon present from a device manufacturer, this will be a rendered version of the system symbol for the device class. Using a rendered system symbol instead of the systemSymbolName is discouraged.
Sourcepub unsafe fn systemSymbolName(&self) -> Option<Retained<NSString>>
pub unsafe fn systemSymbolName(&self) -> Option<Retained<NSString>>
Standard system symbol used to represent the device class. Using the symbol to render an appropriate device icon will ensure proper scaling for high resolution devices.
Sourcepub unsafe fn transportType(&self) -> Option<Retained<NSString>>
pub unsafe fn transportType(&self) -> Option<Retained<NSString>>
The transport type used by the device. The possible values are: ICTransportTypeUSB or ICTransportTypeMassStorage.
Sourcepub unsafe fn UUIDString(&self) -> Option<Retained<NSString>>
pub unsafe fn UUIDString(&self) -> Option<Retained<NSString>>
A string representation of the Universally Unique ID of the device.
Sourcepub unsafe fn locationDescription(&self) -> Option<Retained<NSString>>
pub unsafe fn locationDescription(&self) -> Option<Retained<NSString>>
A non-localized location description string for the device.
The value returned in one of the location description strings defined above, or location obtained from the Bonjour TXT record of a network device.
Sourcepub unsafe fn hasOpenSession(&self) -> bool
pub unsafe fn hasOpenSession(&self) -> bool
Indicates whether the device has an open session.
Sourcepub unsafe fn userData(&self) -> Option<Retained<NSMutableDictionary>>
pub unsafe fn userData(&self) -> Option<Retained<NSMutableDictionary>>
Client convenience bookkeeping object retained by the framework.
Sourcepub unsafe fn modulePath(&self) -> Retained<NSString>
pub unsafe fn modulePath(&self) -> Retained<NSString>
Filesystem path of the device module that is associated with this device. Camera-specific capabilities are defined in ICCameraDevice.h and scanner-specific capabilities are defined in ICScannerDevice.h.
Sourcepub unsafe fn moduleVersion(&self) -> Option<Retained<NSString>>
pub unsafe fn moduleVersion(&self) -> Option<Retained<NSString>>
The bundle version of the device module associated with this device.
Note: This may change if an existing device module associated with this device is updated or a new device module for this device is installed.
Sourcepub unsafe fn serialNumberString(&self) -> Option<Retained<NSString>>
pub unsafe fn serialNumberString(&self) -> Option<Retained<NSString>>
The serial number of the device. This will be NULL if the device does not provide a serial number.
Sourcepub unsafe fn usbLocationID(&self) -> c_int
pub unsafe fn usbLocationID(&self) -> c_int
The USB location of which the device is occupying.
Sourcepub unsafe fn usbProductID(&self) -> c_int
pub unsafe fn usbProductID(&self) -> c_int
The USB PID associated with the device attached.
Sourcepub unsafe fn usbVendorID(&self) -> c_int
pub unsafe fn usbVendorID(&self) -> c_int
The USB VID associated with the device attached.
Sourcepub unsafe fn requestOpenSession(&self)
pub unsafe fn requestOpenSession(&self)
This message requests to open a session on the device.
Make sure the receiver’s delegate is set prior to sending this message; otherwise this message will be ignored. This request is completed when the delegate receives a “device:didOpenSessionWithError:” message.
Note: Execution of the delegate callback will occur on the main thread.
Sourcepub unsafe fn requestCloseSession(&self)
pub unsafe fn requestCloseSession(&self)
This message requests to close a previously opened session on this device.
This request is completed when the delegate receives a “device:didCloseSessionWithError:” message.
Note: Execution of the delegate callback will occur on the main thread.
Sourcepub unsafe fn requestEject(&self)
pub unsafe fn requestEject(&self)
Eject the media if permitted by the device, or disconnect from a remote device.
Sourcepub unsafe fn requestOpenSessionWithOptions_completion(
&self,
options: Option<&NSDictionary<ICSessionOptions, AnyObject>>,
completion: &DynBlock<dyn Fn(*mut NSError)>,
)
Available on crate feature block2
only.
pub unsafe fn requestOpenSessionWithOptions_completion( &self, options: Option<&NSDictionary<ICSessionOptions, AnyObject>>, completion: &DynBlock<dyn Fn(*mut NSError)>, )
block2
only.This message requests to open a session on the device.
This request will execute the completion handler provided upon return.
Note: The completion block will execute on an any available queue, often this will not be the main queue.
Sourcepub unsafe fn requestCloseSessionWithOptions_completion(
&self,
options: Option<&NSDictionary<ICSessionOptions, AnyObject>>,
completion: &DynBlock<dyn Fn(*mut NSError)>,
)
Available on crate feature block2
only.
pub unsafe fn requestCloseSessionWithOptions_completion( &self, options: Option<&NSDictionary<ICSessionOptions, AnyObject>>, completion: &DynBlock<dyn Fn(*mut NSError)>, )
block2
only.This message requests to close a previously opened session on this device.
This request will execute the completion handler provided upon return.
Note: The completion block will execute on an any available queue, often this will not be the main queue.
Sourcepub unsafe fn requestEjectWithCompletion(
&self,
completion: &DynBlock<dyn Fn(*mut NSError)>,
)
Available on crate feature block2
only.
pub unsafe fn requestEjectWithCompletion( &self, completion: &DynBlock<dyn Fn(*mut NSError)>, )
block2
only.Eject the media, or disconnect the device - if permitted by the device.
This request will execute the completion handler provided upon return.
Note: The completion block will execute on an any available queue, often this will not be the main queue.
Sourcepub unsafe fn autolaunchApplicationPath(&self) -> Option<Retained<NSString>>
pub unsafe fn autolaunchApplicationPath(&self) -> Option<Retained<NSString>>
Filesystem path of an application that is to be automatically launched when this device is added.
This property is unavailable for devices of ICTransportTypeProximity.
Sourcepub unsafe fn setAutolaunchApplicationPath(
&self,
autolaunch_application_path: Option<&NSString>,
)
pub unsafe fn setAutolaunchApplicationPath( &self, autolaunch_application_path: Option<&NSString>, )
Setter for autolaunchApplicationPath
.
Sourcepub unsafe fn isRemote(&self) -> bool
pub unsafe fn isRemote(&self) -> bool
Indicates whether the device is a remote device published by Image Capture device sharing facility.
Name of the device as reported by the device module or by the device transport when a device module is not in control of this device.
Note: This name may change if the device module overrides the default name of the device reported by the device’s transport, or if the name of the filesystem volume mounted by the device is changed by the user.
Sourcepub unsafe fn persistentIDString(&self) -> Option<Retained<NSString>>
pub unsafe fn persistentIDString(&self) -> Option<Retained<NSString>>
A string representation of the persistent ID of the device.
Sourcepub unsafe fn requestSendMessage_outData_maxReturnedDataSize_sendMessageDelegate_didSendMessageSelector_contextInfo(
&self,
message_code: c_uint,
data: &NSData,
max_returned_data_size: c_uint,
send_message_delegate: &AnyObject,
selector: Sel,
context_info: *mut c_void,
)
pub unsafe fn requestSendMessage_outData_maxReturnedDataSize_sendMessageDelegate_didSendMessageSelector_contextInfo( &self, message_code: c_uint, data: &NSData, max_returned_data_size: c_uint, send_message_delegate: &AnyObject, selector: Sel, context_info: *mut c_void, )
This method asynchronously sends an arbitrary message with optional data to a device.
This method allows developers to send a private message from a client application to a device module.
The response to this command will be delivered using didSendMessageSelector of sendMessageDelegate. The didSendMessageSelector should have the same signature as: - (void)didSendMessage:(UInt32)messageCode inData:(NSData*)data error:(NSError*)error contextInfo:(void*)contextInfo.
The content of error returned should be examined to determine if the request completed successfully.
Note: This method should not be used to send PTP pass-through commands to a PTP camera. Please refer to ‘requestSendPTPCommand:outData:sendCommandDelegate:sendCommandDelegate:contextInfo:’ defined in ICCameraDevice.h for sending PTP pass-through commands.
Note: Execution of the delegate callback will occur on the main thread.
Sourcepub unsafe fn requestEjectOrDisconnect(&self)
👎Deprecated
pub unsafe fn requestEjectOrDisconnect(&self)
Eject the media if permitted by the device, or disconnect from a remote device.
Sourcepub unsafe fn requestYield(&self)
👎Deprecated: Requesting a device yield is no longer avaialble
pub unsafe fn requestYield(&self)
This message requests the device module in control of this device to yield control.
This message should be used only if the client is planning on communicating with the device directly. The device module may not yield control of the device if it has an open session.
Sourcepub unsafe fn moduleExecutableArchitecture(&self) -> c_int
👎Deprecated: Module executable architecture is no longer available
pub unsafe fn moduleExecutableArchitecture(&self) -> c_int
Reports the device module servicing the requests executable architecture.
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 ICCameraDevice
impl AsRef<AnyObject> for ICCameraDevice
Source§impl AsRef<ICCameraDevice> for ICCameraDevice
impl AsRef<ICCameraDevice> for ICCameraDevice
Source§impl AsRef<ICDevice> for ICCameraDevice
impl AsRef<ICDevice> for ICCameraDevice
Source§impl AsRef<NSObject> for ICCameraDevice
impl AsRef<NSObject> for ICCameraDevice
Source§impl Borrow<AnyObject> for ICCameraDevice
impl Borrow<AnyObject> for ICCameraDevice
Source§impl Borrow<ICDevice> for ICCameraDevice
impl Borrow<ICDevice> for ICCameraDevice
Source§impl Borrow<NSObject> for ICCameraDevice
impl Borrow<NSObject> for ICCameraDevice
Source§impl ClassType for ICCameraDevice
impl ClassType for ICCameraDevice
Source§const NAME: &'static str = "ICCameraDevice"
const NAME: &'static str = "ICCameraDevice"
Source§type ThreadKind = <<ICCameraDevice as ClassType>::Super as ClassType>::ThreadKind
type ThreadKind = <<ICCameraDevice as ClassType>::Super as ClassType>::ThreadKind
Source§impl Debug for ICCameraDevice
impl Debug for ICCameraDevice
Source§impl Deref for ICCameraDevice
impl Deref for ICCameraDevice
Source§impl Hash for ICCameraDevice
impl Hash for ICCameraDevice
Source§impl Message for ICCameraDevice
impl Message for ICCameraDevice
Source§impl NSObjectProtocol for ICCameraDevice
impl NSObjectProtocol for ICCameraDevice
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