pub struct IOUSBHostInterface { /* private fields */ }IOUSBHostInterface and IOUSBHostObject only.Expand description
The IOUSBHostObject representing a USB interface
This class provides functionality to send control requests to the default control endpoint, as well as create IOUSBHostPipe objects to transfer data.
See also Apple’s documentation
Implementations§
Source§impl IOUSBHostInterface
impl IOUSBHostInterface
Sourcepub unsafe fn createMatchingDictionaryWithVendorID_productID_bcdDevice_interfaceNumber_configurationValue_interfaceClass_interfaceSubclass_interfaceProtocol_speed_productIDArray(
vendor_id: Option<&NSNumber>,
product_id: Option<&NSNumber>,
bcd_device: Option<&NSNumber>,
interface_number: Option<&NSNumber>,
configuration_value: Option<&NSNumber>,
interface_class: Option<&NSNumber>,
interface_subclass: Option<&NSNumber>,
interface_protocol: Option<&NSNumber>,
speed: Option<&NSNumber>,
product_id_array: Option<&NSArray>,
) -> Retained<CFMutableDictionary>
Available on crate feature objc2-core-foundation only.
pub unsafe fn createMatchingDictionaryWithVendorID_productID_bcdDevice_interfaceNumber_configurationValue_interfaceClass_interfaceSubclass_interfaceProtocol_speed_productIDArray( vendor_id: Option<&NSNumber>, product_id: Option<&NSNumber>, bcd_device: Option<&NSNumber>, interface_number: Option<&NSNumber>, configuration_value: Option<&NSNumber>, interface_class: Option<&NSNumber>, interface_subclass: Option<&NSNumber>, interface_protocol: Option<&NSNumber>, speed: Option<&NSNumber>, product_id_array: Option<&NSArray>, ) -> Retained<CFMutableDictionary>
objc2-core-foundation only.Creates a matching dictionary for an IOUSBHostInterface to be passed into IOServiceGetMatchingService
Parameter vendorID: NSNumber representation of device vendorID
Parameter productID: NSNumber representation of device productID
Parameter bcdDevice: NSNumber representation of device release number
Parameter interfaceNumber: NSNumber representation of interface number
Parameter configurationValue: NSNumber representation of the device’s configurationValue
Parameter interfaceClass: NSNumber representation of interface class
Parameter interfaceSubclass: NSNumber representation of interface subclass
Parameter interfaceProtocol: NSNumber representation of interface protocol
Parameter speed: NSNumber representation of device speed
Parameter productIDArray: NSArray of NSNumbers representing all productIDs interested in.
If used do not specify the NSNumber productID field
Returns: CFMutableDictionaryRef to be used with IOService matching methods. To be released by caller.
§Safety
product_id_arraygeneric should be of the correct type.- The returned generics must be of the correct type.
Sourcepub unsafe fn initWithIOService_options_queue_error_interestHandler(
this: Allocated<Self>,
io_service: io_service_t,
options: IOUSBHostObjectInitOptions,
queue: Option<&DispatchQueue>,
error: Option<&mut Option<Retained<NSError>>>,
interest_handler: IOUSBHostInterestHandler,
) -> Option<Retained<Self>>
Available on crate features IOUSBHostDefinitions and block2 and dispatch2 and objc2-io-kit only.
pub unsafe fn initWithIOService_options_queue_error_interestHandler( this: Allocated<Self>, io_service: io_service_t, options: IOUSBHostObjectInitOptions, queue: Option<&DispatchQueue>, error: Option<&mut Option<Retained<NSError>>>, interest_handler: IOUSBHostInterestHandler, ) -> Option<Retained<Self>>
IOUSBHostDefinitions and block2 and dispatch2 and objc2-io-kit only.Initializes IOUSBHostInterface object along with user client
See IOUSBHostObject for documentation.
§Safety
queuepossibly has additional threading requirements.interest_handlermust be a valid pointer or null.
Sourcepub unsafe fn idleTimeout(&self) -> NSTimeInterval
pub unsafe fn idleTimeout(&self) -> NSTimeInterval
Retrieve the current idle suspend timeout. See
setIdleTimeoutReturns: The amount of time after all pipes are idle to wait before suspending the device,
Sourcepub unsafe fn setIdleTimeout_error(
&self,
idle_timeout: NSTimeInterval,
) -> Result<(), Retained<NSError>>
pub unsafe fn setIdleTimeout_error( &self, idle_timeout: NSTimeInterval, ) -> Result<(), Retained<NSError>>
Sets the desired idle suspend timeout for the interface
Once the interface is considered idle, it will defer electrical suspend of the device for the specified duration.
Parameter idleTimeout: The amount of time after all pipes are idle to
wait before suspending the device.
Returns: YES on success. An IOReturn error code will be reported on failure.
Sourcepub unsafe fn configurationDescriptor(
&self,
) -> NonNull<IOUSBConfigurationDescriptor>
Available on crate feature objc2-io-kit only.
pub unsafe fn configurationDescriptor( &self, ) -> NonNull<IOUSBConfigurationDescriptor>
objc2-io-kit only.Retrieve the configuration descriptor associated with this interface
Returns: IOUSBConfigurationDescriptor pointer
Sourcepub unsafe fn interfaceDescriptor(&self) -> NonNull<IOUSBInterfaceDescriptor>
Available on crate feature objc2-io-kit only.
pub unsafe fn interfaceDescriptor(&self) -> NonNull<IOUSBInterfaceDescriptor>
objc2-io-kit only.Retrieve the interface descriptor associated with this interface.
Returns: IOUSBInterfaceDescriptor pointer
Sourcepub unsafe fn selectAlternateSetting_error(
&self,
alternate_setting: NSUInteger,
) -> Result<(), Retained<NSError>>
pub unsafe fn selectAlternateSetting_error( &self, alternate_setting: NSUInteger, ) -> Result<(), Retained<NSError>>
Select an alternate setting for this interface
This method is used to select an alternate setting for the interface. All pending IO on the interface’s pipes will be aborted, and the open pipes will be closed. The IOUSBHostPipe objects already created will no longer be valid. The new alternate setting will be selected via SET_INTERFACE control request (USB 2.0 9.4.10).
Parameter alternateSetting: Alternate interface number to activate
Returns: YES on success, an IOReturn error code will be reported on failure.
Sourcepub unsafe fn copyPipeWithAddress_error(
&self,
address: NSUInteger,
) -> Result<Retained<IOUSBHostPipe>, Retained<NSError>>
Available on crate features IOUSBHostIOSource and IOUSBHostPipe only.
pub unsafe fn copyPipeWithAddress_error( &self, address: NSUInteger, ) -> Result<Retained<IOUSBHostPipe>, Retained<NSError>>
IOUSBHostIOSource and IOUSBHostPipe only.Return the pipe whose
bEndpointAddress
matches
address
This method will return the pipe whose
bEndpointAddress
matches
address
. If the pipe is returned successfully, it will maintain
a reference to the IOUSBHostInterface.
Parameter address: Endpoint address of the pipe
Returns: Pointer to an IOUSBHostPipe object or nil. The IOUSBHostPipe is to be released by the caller. An IOReturn error code will be reported on failure.
Source§impl IOUSBHostInterface
Methods declared on superclass IOUSBHostObject.
impl IOUSBHostInterface
Methods declared on superclass IOUSBHostObject.
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>
Sourcepub unsafe fn initWithIOService_queue_error_interestHandler(
this: Allocated<Self>,
io_service: io_service_t,
queue: Option<&DispatchQueue>,
error: Option<&mut Option<Retained<NSError>>>,
interest_handler: IOUSBHostInterestHandler,
) -> Option<Retained<Self>>
Available on crate features block2 and dispatch2 and objc2-io-kit only.
pub unsafe fn initWithIOService_queue_error_interestHandler( this: Allocated<Self>, io_service: io_service_t, queue: Option<&DispatchQueue>, error: Option<&mut Option<Retained<NSError>>>, interest_handler: IOUSBHostInterestHandler, ) -> Option<Retained<Self>>
block2 and dispatch2 and objc2-io-kit only.Initializes IOUSBHostObject object along with user client
This method should be called from either IOUSBHostDevice or IOUSBHostInterface. If the io_service_t is not found nil will be returned. If an IOUSBHostDevice or IOUSBHostInterface user client is already created, nil will be returned. Upon creation, exclusive ownership of the IOService will be established. When done using the object destroy must be called on the object.
Parameter ioService: io_service_t of the IOUSBHostDevice or IOUSBHostInterface
the user client is for. The IOUSBHostObject will keep a reference to the io_service_t
and release it after the IOUSBHostObject has been released.
Parameter queue: A serial queue that all asynchronous io will be serviced. By
default a serial queue will be created on behalf of the client. Setting
a queue will create a dispatch source event handler for the target queue to service
all underlying io.
Parameter interestHandler: IOUSBHostInterestHandler a generalInterest IOService handler. This is
to handle underlying service state changes such as termination. See
IOServiceAddInterestNotification in IOKitLib for more details. All notifications will be serviced
on an internal serial queue separate from the IO queue.
Returns: An IOUSBHostDevice or IOUSBHostInterface. The object is to be released by the caller. An IOReturn error code will be reported on failure.
§Safety
queuepossibly has additional threading requirements.interest_handlermust be a valid pointer or null.
Methods from Deref<Target = IOUSBHostObject>§
Sourcepub unsafe fn destroy(&self)
pub unsafe fn destroy(&self)
Removes underlying allocations of the IOUSBHostObject object along with user client
When the IOUSBHostObject is no longer needed, destroy must be called. This will destroy the connection with the user client and de-register interest on the service. If the object is free’d destroy will be called automatically. Calling destroy multiple times has no effect.
Sourcepub unsafe fn destroyWithOptions(&self, options: IOUSBHostObjectDestroyOptions)
Available on crate feature IOUSBHostDefinitions only.
pub unsafe fn destroyWithOptions(&self, options: IOUSBHostObjectDestroyOptions)
IOUSBHostDefinitions only.Removes underlying allocations of the IOUSBHostObject object along with user client
Extends
destroy
to take an options to modify the destroy behavior. Currently only the
IOUSBHostObjectDestroyOptionsDeviceSurrender
is defined to support surrendering ownersip of
the kernel service. To be used when accepting the
kUSBHostMessageDeviceIsRequestingClose
message.
Sourcepub unsafe fn ioService(&self) -> io_service_t
Available on crate feature objc2-io-kit only.
pub unsafe fn ioService(&self) -> io_service_t
objc2-io-kit only.Retrieve the IOUSBHostObject’s io_service_t.
Sourcepub unsafe fn queue(&self) -> Retained<DispatchQueue>
Available on crate feature dispatch2 only.
pub unsafe fn queue(&self) -> Retained<DispatchQueue>
dispatch2 only.The dispatch queue that all asynchronous io will be serviced.
Sourcepub unsafe fn sendDeviceRequest_data_bytesTransferred_completionTimeout_error(
&self,
request: IOUSBDeviceRequest,
data: Option<&NSMutableData>,
bytes_transferred: *mut NSUInteger,
completion_timeout: NSTimeInterval,
) -> Result<(), Retained<NSError>>
Available on crate feature objc2-io-kit only.
pub unsafe fn sendDeviceRequest_data_bytesTransferred_completionTimeout_error( &self, request: IOUSBDeviceRequest, data: Option<&NSMutableData>, bytes_transferred: *mut NSUInteger, completion_timeout: NSTimeInterval, ) -> Result<(), Retained<NSError>>
objc2-io-kit only.Send a request on the default control endpoint
This method will send a synchronous request on the default control endpoint, and will not return until the request is complete.
Parameter request: IOUSBDeviceRequest structure.
Parameter data: An NSMutableData* defining the memory to use for the request’s data phase.
Parameter bytesTransferred: Optional NSUInteger reference which will be updated with the byte
count of the completed data phase.
Parameter completionTimeout: Timeout of the request. If 0, the request will never timeout. By
default this value is IOUSBHostDefaultControlCompletionTimeout.
Returns: YES on success, an IOReturn error code will be reported on failure.
§Safety
bytes_transferred must be a valid pointer or null.
Sourcepub unsafe fn sendDeviceRequest_data_bytesTransferred_error(
&self,
request: IOUSBDeviceRequest,
data: Option<&NSMutableData>,
bytes_transferred: *mut NSUInteger,
) -> Result<(), Retained<NSError>>
Available on crate feature objc2-io-kit only.
pub unsafe fn sendDeviceRequest_data_bytesTransferred_error( &self, request: IOUSBDeviceRequest, data: Option<&NSMutableData>, bytes_transferred: *mut NSUInteger, ) -> Result<(), Retained<NSError>>
objc2-io-kit only.Send a request on the default control endpoint
This method will send a synchronous request on the default control endpoint, and will not return until the request is complete.
Parameter request: IOUSBDeviceRequest structure.
Parameter data: An NSMutableData* defining the memory to use for the request’s data phase.
Parameter bytesTransferred: Optional NSUInteger reference which will be updated with the byte
count of the completed data phase.
Returns: YES on success, an IOReturn error code will be reported on failure.
§Safety
bytes_transferred must be a valid pointer or null.
Sourcepub unsafe fn sendDeviceRequest_error(
&self,
request: IOUSBDeviceRequest,
) -> Result<(), Retained<NSError>>
Available on crate feature objc2-io-kit only.
pub unsafe fn sendDeviceRequest_error( &self, request: IOUSBDeviceRequest, ) -> Result<(), Retained<NSError>>
objc2-io-kit only.Send a request on the default control endpoint
This method will send a synchronous request on the default control endpoint, and will not return until the request is complete.
Parameter request: IOUSBDeviceRequest structure.
Returns: YES on success, an IOReturn error code will be reported on failure.
Sourcepub unsafe fn enqueueDeviceRequest_data_completionTimeout_error_completionHandler(
&self,
request: IOUSBDeviceRequest,
data: Option<&NSMutableData>,
completion_timeout: NSTimeInterval,
error: Option<&mut Option<Retained<NSError>>>,
completion_handler: IOUSBHostCompletionHandler,
) -> bool
Available on crate features IOUSBHostDefinitions and block2 and objc2-io-kit only.
pub unsafe fn enqueueDeviceRequest_data_completionTimeout_error_completionHandler( &self, request: IOUSBDeviceRequest, data: Option<&NSMutableData>, completion_timeout: NSTimeInterval, error: Option<&mut Option<Retained<NSError>>>, completion_handler: IOUSBHostCompletionHandler, ) -> bool
IOUSBHostDefinitions and block2 and objc2-io-kit only.Enqueue a request on the default control endpoint
This method will enqueue an asynchronous request on the default control endpoint. If successful, the provided completionHandler will be called to report the status of the completed IO.
Parameter data: An NSMutableData* defining the memory to use for the request’s data phase.
Parameter completionTimeout: Timeout of the request. If 0, the request will never timeout. By
default this value is IOUSBHostDefaultControlCompletionTimeout
Parameter completionHandler: an IOUSBHostCompletionHandler
Returns: YES on success, an IOReturn error code will be reported on failure
§Safety
completion_handler must be a valid pointer or null.
Sourcepub unsafe fn enqueueDeviceRequest_data_error_completionHandler(
&self,
request: IOUSBDeviceRequest,
data: Option<&NSMutableData>,
error: Option<&mut Option<Retained<NSError>>>,
completion_handler: IOUSBHostCompletionHandler,
) -> bool
Available on crate features IOUSBHostDefinitions and block2 and objc2-io-kit only.
pub unsafe fn enqueueDeviceRequest_data_error_completionHandler( &self, request: IOUSBDeviceRequest, data: Option<&NSMutableData>, error: Option<&mut Option<Retained<NSError>>>, completion_handler: IOUSBHostCompletionHandler, ) -> bool
IOUSBHostDefinitions and block2 and objc2-io-kit only.Enqueue a request on the default control endpoint
This method will enqueue an asynchronous request on the default control endpoint. If successful, the provided completionHandler will be called to report the status of the completed IO.
Parameter data: An NSMutableData* defining the memory to use for the request’s data phase.
Parameter completionHandler: an IOUSBHostCompletionHandler
Returns: YES on success, an IOReturn error code will be reported on failure
§Safety
completion_handler must be a valid pointer or null.
Sourcepub unsafe fn enqueueDeviceRequest_error_completionHandler(
&self,
request: IOUSBDeviceRequest,
error: Option<&mut Option<Retained<NSError>>>,
completion_handler: IOUSBHostCompletionHandler,
) -> bool
Available on crate features IOUSBHostDefinitions and block2 and objc2-io-kit only.
pub unsafe fn enqueueDeviceRequest_error_completionHandler( &self, request: IOUSBDeviceRequest, error: Option<&mut Option<Retained<NSError>>>, completion_handler: IOUSBHostCompletionHandler, ) -> bool
IOUSBHostDefinitions and block2 and objc2-io-kit only.Enqueue a request on the default control endpoint
This method will enqueue an asynchronous request on the default control endpoint. If successful, the provided completionHandler will be called to report the status of the completed IO. default this value is IOUSBHostDefaultControlCompletionTimeout
Parameter completionHandler: an IOUSBHostCompletionHandler
Returns: YES on success, an IOReturn error code will be reported on failure
§Safety
completion_handler must be a valid pointer or null.
Sourcepub unsafe fn abortDeviceRequestsWithOption_error(
&self,
option: IOUSBHostAbortOption,
) -> Result<(), Retained<NSError>>
Available on crate feature IOUSBHostDefinitions only.
pub unsafe fn abortDeviceRequestsWithOption_error( &self, option: IOUSBHostAbortOption, ) -> Result<(), Retained<NSError>>
IOUSBHostDefinitions only.Abort device requests
This method will abort any requests made via the
sendDeviceRequestand
enqueueDeviceRequestmethods.
Parameter option: IOUSBHostAbortOption by default IOUSBHostAbortOptionSynchronous is used
Returns: YES on success, an IOReturn error code will be reported on failure
Sourcepub unsafe fn abortDeviceRequestsWithError(
&self,
) -> Result<(), Retained<NSError>>
pub unsafe fn abortDeviceRequestsWithError( &self, ) -> Result<(), Retained<NSError>>
Abort device requests
This method will abort any requests made via the
sendDeviceRequestand
enqueueDeviceRequestmethods.
Returns: YES on success, an IOReturn error code will be reported on failure
Sourcepub unsafe fn descriptorWithType_length_index_languageID_requestType_requestRecipient_error(
&self,
type: tIOUSBDescriptorType,
length: NonNull<NSUInteger>,
index: NSUInteger,
language_id: NSUInteger,
request_type: tIOUSBDeviceRequestTypeValue,
request_recipient: tIOUSBDeviceRequestRecipientValue,
error: Option<&mut Option<Retained<NSError>>>,
) -> *const IOUSBDescriptor
Available on crate feature objc2-io-kit only.
pub unsafe fn descriptorWithType_length_index_languageID_requestType_requestRecipient_error( &self, type: tIOUSBDescriptorType, length: NonNull<NSUInteger>, index: NSUInteger, language_id: NSUInteger, request_type: tIOUSBDeviceRequestTypeValue, request_recipient: tIOUSBDeviceRequestRecipientValue, error: Option<&mut Option<Retained<NSError>>>, ) -> *const IOUSBDescriptor
objc2-io-kit only.Retrieve a descriptor from the cache or the device
This method will search the descriptor cache for the descriptor that matches the input arguments. If the descriptor is not in the cache, a GET_DESCRIPTOR control request (USB 2.0 9.4.3) will be issued to retrieve the descriptor from the device. If the device request is successful, the retrieved descriptor will be added to the cache.
Parameter type:
bDescriptorType
of the descriptor to find.
Parameter length: Reference to a NSUInteger which will be updated with the length of the
descriptor. As input, used as
wLength
when fetching variable-length
configuration or BOS descriptors, or when fetching nonstandard descriptor types.
Parameter index: Descriptor index value. Low byte of
wValue
of the SET_DESCRIPTOR
control request (USB 2.0 9.4.8). By default the value is 0
Parameter languageID: Descriptor language ID.
wIndex
of the SET_DESCRIPTOR
control request (USB 2.0 9.4.8). By default the value is 0
Parameter requestType: tDeviceRequestType to be used for a GET_DESCRIPTOR control request.
By default the value is IOUSBRequestTypeStandard
Parameter requestRecipient: tDeviceRequestRecipient to be used for a GET_DESCRIPTOR control
request. By default the value is IOUSBRequestRecipientDevice
Returns: Pointer to the cached descriptor if found, otherwise nil. An IOReturn error code will be reported on failure.
§Safety
length must be a valid pointer.
Sourcepub unsafe fn descriptorWithType_length_index_languageID_error(
&self,
type: tIOUSBDescriptorType,
length: NonNull<NSUInteger>,
index: NSUInteger,
language_id: NSUInteger,
error: Option<&mut Option<Retained<NSError>>>,
) -> *const IOUSBDescriptor
Available on crate feature objc2-io-kit only.
pub unsafe fn descriptorWithType_length_index_languageID_error( &self, type: tIOUSBDescriptorType, length: NonNull<NSUInteger>, index: NSUInteger, language_id: NSUInteger, error: Option<&mut Option<Retained<NSError>>>, ) -> *const IOUSBDescriptor
objc2-io-kit only.Retrieve a descriptor from the cache or the device
This method will search the descriptor cache for the descriptor that matches the input arguments. If the descriptor is not in the cache, a GET_DESCRIPTOR control request (USB 2.0 9.4.3) will be issued to retrieve the descriptor from the device. If the device request is successful, the retrieved descriptor will be added to the cache.
Parameter type:
bDescriptorType
of the descriptor to find.
Parameter length: Reference to a NSUInteger which will be updated with the length of the
descriptor. As input, used as
wLength
when fetching variable-length
configuration or BOS descriptors, or when fetching nonstandard descriptor types.
Parameter index: Descriptor index value. Low byte of
wValue
of the SET_DESCRIPTOR
control request (USB 2.0 9.4.8). By default the value is 0
Parameter languageID: Descriptor language ID.
wIndex
of the SET_DESCRIPTOR
control request (USB 2.0 9.4.8). By default the value is 0
Returns: Pointer to the cached descriptor if found, otherwise nil. An IOReturn error code will be reported on failure.
§Safety
length must be a valid pointer.
Sourcepub unsafe fn descriptorWithType_length_error(
&self,
type: tIOUSBDescriptorType,
length: NonNull<NSUInteger>,
error: Option<&mut Option<Retained<NSError>>>,
) -> *const IOUSBDescriptor
Available on crate feature objc2-io-kit only.
pub unsafe fn descriptorWithType_length_error( &self, type: tIOUSBDescriptorType, length: NonNull<NSUInteger>, error: Option<&mut Option<Retained<NSError>>>, ) -> *const IOUSBDescriptor
objc2-io-kit only.Retrieve a descriptor from the cache or the device
This method will search the descriptor cache for the descriptor that matches the input arguments. If the descriptor is not in the cache, a GET_DESCRIPTOR control request (USB 2.0 9.4.3) will be issued to retrieve the descriptor from the device. If the device request is successful, the retrieved descriptor will be added to the cache.
Parameter type:
bDescriptorType
of the descriptor to find.
Parameter length: Reference to a NSUInteger which will be updated with the length of the
descriptor. As input, used as
wLength
when fetching variable-length
configuration or BOS descriptors, or when fetching nonstandard descriptor types.
By default the value is 0
Returns: Pointer to the cached descriptor if found, otherwise nil. An IOReturn error code will be reported on failure.
§Safety
length must be a valid pointer.
Sourcepub unsafe fn deviceDescriptor(&self) -> *const IOUSBDeviceDescriptor
Available on crate feature objc2-io-kit only.
pub unsafe fn deviceDescriptor(&self) -> *const IOUSBDeviceDescriptor
objc2-io-kit only.Return the device descriptor
This method uses descriptorWithType to retrieve the device descriptor.
Returns: Pointer to the device descriptor.
Sourcepub unsafe fn capabilityDescriptors(&self) -> *const IOUSBBOSDescriptor
Available on crate feature objc2-io-kit only.
pub unsafe fn capabilityDescriptors(&self) -> *const IOUSBBOSDescriptor
objc2-io-kit only.Return the capability descriptors of the device
This method uses descriptorWithType to return the device’s BOS descriptors
Returns: Pointer to the BOS descriptor if found, otherwise nil.
Sourcepub unsafe fn configurationDescriptorWithIndex_error(
&self,
index: NSUInteger,
error: Option<&mut Option<Retained<NSError>>>,
) -> *const IOUSBConfigurationDescriptor
Available on crate feature objc2-io-kit only.
pub unsafe fn configurationDescriptorWithIndex_error( &self, index: NSUInteger, error: Option<&mut Option<Retained<NSError>>>, ) -> *const IOUSBConfigurationDescriptor
objc2-io-kit only.Return the configuration descriptor at a specified index
This method uses descriptorWithType to retrieve the configuration descriptor.
Parameter index: Descriptor index value
Returns: Pointer of the configuration descriptor if found, otherwise nil. An IOReturn error code will be reported on failure.
Sourcepub unsafe fn configurationDescriptorWithConfigurationValue_error(
&self,
configuration_value: NSUInteger,
error: Option<&mut Option<Retained<NSError>>>,
) -> *const IOUSBConfigurationDescriptor
Available on crate feature objc2-io-kit only.
pub unsafe fn configurationDescriptorWithConfigurationValue_error( &self, configuration_value: NSUInteger, error: Option<&mut Option<Retained<NSError>>>, ) -> *const IOUSBConfigurationDescriptor
objc2-io-kit only.Return the configuration descriptor with a specified value
This method uses descriptorWithType to search for a configuration descriptor with a
specific
bConfigurationValue
field.
Parameter configurationValue: Value to match
Returns: Pointer of the configuration descriptor if found, otherwise nil. An IOReturn error code will be reported on failure.
Sourcepub unsafe fn stringWithIndex_languageID_error(
&self,
index: NSUInteger,
language_id: NSUInteger,
) -> Result<Retained<NSString>, Retained<NSError>>
pub unsafe fn stringWithIndex_languageID_error( &self, index: NSUInteger, language_id: NSUInteger, ) -> Result<Retained<NSString>, Retained<NSError>>
Returns the string from a string descriptor
This method uses descriptorWithType to retrieve the string descriptor.
Parameter index: Descriptor index value. Low byte of
wValue
of the
SET_DESCRIPTOR control request (USB 2.0 9.4.8).
Parameter languageID: Descriptor language ID.
wIndex
of the SET_DESCRIPTOR
control request (USB 2.0 9.4.8). By default this value is kLanguageIDEnglishUS
Returns: NSString reference to string from descriptor, an IOReturn error code will be reported on failure.
Sourcepub unsafe fn stringWithIndex_error(
&self,
index: NSUInteger,
) -> Result<Retained<NSString>, Retained<NSError>>
pub unsafe fn stringWithIndex_error( &self, index: NSUInteger, ) -> Result<Retained<NSString>, Retained<NSError>>
Returns the string from a string descriptor
This method uses descriptorWithType to retrieve the string descriptor.
Parameter index: Descriptor index value. Low byte of
wValue
of the
SET_DESCRIPTOR control request (USB 2.0 9.4.8).
Returns: NSString reference to string from descriptor, an IOReturn error code will be reported on failure.
Sourcepub unsafe fn deviceAddress(&self) -> NSUInteger
pub unsafe fn deviceAddress(&self) -> NSUInteger
Retrieve the current address of the device.
Sourcepub unsafe fn frameNumberWithTime(&self, time: *mut IOUSBHostTime) -> u64
Available on crate feature IOUSBHostDefinitions only.
pub unsafe fn frameNumberWithTime(&self, time: *mut IOUSBHostTime) -> u64
IOUSBHostDefinitions only.Return the current frame number of the USB controller
This method will return the current frame number of the USB controller, omitting micro frame. This is most useful for scheduling future isochronous requests.
Parameter time: If not nil, this will be updated with the current system time
Returns: The current frame number
§Safety
time must be a valid pointer or null.
Sourcepub unsafe fn currentMicroframeWithTime_error(
&self,
time: *mut IOUSBHostTime,
error: Option<&mut Option<Retained<NSError>>>,
) -> u64
Available on crate feature IOUSBHostDefinitions only.
pub unsafe fn currentMicroframeWithTime_error( &self, time: *mut IOUSBHostTime, error: Option<&mut Option<Retained<NSError>>>, ) -> u64
IOUSBHostDefinitions only.Return the current microframe number of the USB controller
This method will return the current microframe number of the USB controller. This is most useful for scheduling future isochronous requests.
Parameter time: If not nil, this will be updated with system time associated with the microframe.
Returns: The current microframe number. Returns 0 on failure, with NSError populated with the IOReturn error code.
§Safety
time must be a valid pointer or null.
Sourcepub unsafe fn referenceMicroframeWithTime_error(
&self,
time: *mut IOUSBHostTime,
error: Option<&mut Option<Retained<NSError>>>,
) -> u64
Available on crate feature IOUSBHostDefinitions only.
pub unsafe fn referenceMicroframeWithTime_error( &self, time: *mut IOUSBHostTime, error: Option<&mut Option<Retained<NSError>>>, ) -> u64
IOUSBHostDefinitions only.Return a recent microframe number of the USB controller
This method will return a recent microframe number of the USB controller. This is most useful for scheduling future isochronous requests.
Parameter time: If not nil, this will be updated with system time associated with the microframe.
Returns: A recent microframe number. Returns 0 on failure, with NSError populated with the IOReturn error code.
§Safety
time must be a valid pointer or null.
Sourcepub unsafe fn ioDataWithCapacity_error(
&self,
capacity: NSUInteger,
) -> Result<Retained<NSMutableData>, Retained<NSError>>
pub unsafe fn ioDataWithCapacity_error( &self, capacity: NSUInteger, ) -> Result<Retained<NSMutableData>, Retained<NSError>>
Allocate a buffer to be used for I/O
This method will allocate and map an IOBufferMemoryDescriptor optimized for use by the underlying controller hardware. A buffer allocated by this method will not be bounced to perform DMA operations. Because the NSMutableData is backed by kernel memory, the length and capacity are not mutable. Any changes to the length or capacity will cause an exception to be thrown.
Parameter capacity: Size of the buffer to allocate
Returns: NSMutableData of memory mapped to user space of an IOBufferMemoryDescriptor if successful, otherwise nil. An IOReturn error code will be reported on failure. The result is to be released by the caller
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 IOUSBHostInterface
impl AsRef<AnyObject> for IOUSBHostInterface
Source§impl AsRef<IOUSBHostInterface> for IOUSBHostInterface
impl AsRef<IOUSBHostInterface> for IOUSBHostInterface
Source§impl AsRef<IOUSBHostObject> for IOUSBHostInterface
impl AsRef<IOUSBHostObject> for IOUSBHostInterface
Source§fn as_ref(&self) -> &IOUSBHostObject
fn as_ref(&self) -> &IOUSBHostObject
Source§impl AsRef<NSObject> for IOUSBHostInterface
impl AsRef<NSObject> for IOUSBHostInterface
Source§impl Borrow<AnyObject> for IOUSBHostInterface
impl Borrow<AnyObject> for IOUSBHostInterface
Source§impl Borrow<IOUSBHostObject> for IOUSBHostInterface
impl Borrow<IOUSBHostObject> for IOUSBHostInterface
Source§fn borrow(&self) -> &IOUSBHostObject
fn borrow(&self) -> &IOUSBHostObject
Source§impl Borrow<NSObject> for IOUSBHostInterface
impl Borrow<NSObject> for IOUSBHostInterface
Source§impl ClassType for IOUSBHostInterface
impl ClassType for IOUSBHostInterface
Source§const NAME: &'static str = "IOUSBHostInterface"
const NAME: &'static str = "IOUSBHostInterface"
Source§type Super = IOUSBHostObject
type Super = IOUSBHostObject
Source§type ThreadKind = <<IOUSBHostInterface as ClassType>::Super as ClassType>::ThreadKind
type ThreadKind = <<IOUSBHostInterface as ClassType>::Super as ClassType>::ThreadKind
Source§impl Debug for IOUSBHostInterface
impl Debug for IOUSBHostInterface
Source§impl Deref for IOUSBHostInterface
impl Deref for IOUSBHostInterface
Source§impl Hash for IOUSBHostInterface
impl Hash for IOUSBHostInterface
Source§impl Message for IOUSBHostInterface
impl Message for IOUSBHostInterface
Source§impl NSObjectProtocol for IOUSBHostInterface
impl NSObjectProtocol for IOUSBHostInterface
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