pub struct IOUSBHostControllerInterface { /* private fields */ }IOUSBHostControllerInterface only.Expand description
Implementations§
Source§impl IOUSBHostControllerInterface
impl IOUSBHostControllerInterface
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>
Sourcepub unsafe fn initWithCapabilities_queue_interruptRateHz_error_commandHandler_doorbellHandler_interestHandler(
this: Allocated<Self>,
capabilities: &NSData,
queue: Option<&DispatchQueue>,
interrupt_rate_hz: NSUInteger,
error: Option<&mut Option<Retained<NSError>>>,
command_handler: IOUSBHostControllerInterfaceCommandHandler,
doorbell_handler: IOUSBHostControllerInterfaceDoorbellHandler,
interest_handler: IOServiceInterestCallback,
) -> Option<Retained<Self>>
Available on crate features IOUSBHostControllerInterfaceDefinitions and block2 and dispatch2 and objc2-io-kit only.
pub unsafe fn initWithCapabilities_queue_interruptRateHz_error_commandHandler_doorbellHandler_interestHandler( this: Allocated<Self>, capabilities: &NSData, queue: Option<&DispatchQueue>, interrupt_rate_hz: NSUInteger, error: Option<&mut Option<Retained<NSError>>>, command_handler: IOUSBHostControllerInterfaceCommandHandler, doorbell_handler: IOUSBHostControllerInterfaceDoorbellHandler, interest_handler: IOServiceInterestCallback, ) -> Option<Retained<Self>>
IOUSBHostControllerInterfaceDefinitions and block2 and dispatch2 and objc2-io-kit only.Initializes IOUSBHostControllerInterface object along with a user client
If the user client cannot be created, nil will be returned. When done using the object, destroy must be called on the object.
Parameter capabilities: NSData containing an array of IOUSBHostCIMessage structures. The first must have an IOUSBHostCIMessageControlType of IOUSBHostCIMessageTypeControllerCapabilities,
followed by at least one message with an IOUSBHostCIMessageControlType of IOUSBHostCIMessageTypePortCapabilities.
Parameter queue: A serial queue to service asynchronous operations. If nil, a serial queue will be created on behalf of the client.
Parameter interruptRateHz: NSUInteger representing the rate in Hz at which interrupts will be delivered to the kernel driver.
A value ot 0 will send all interrupts to the kernel immediately.
Parameter commandHandler: IOUSBHostControllerInterfaceCommandHandler used to process IOUSBHostCIMessage messages sent by the kernel driver.
Parameter doorbellHandler: IOUSBHostControllerInterfaceDoorbellHandler used to process IOUSBHostCIDoorbell values sent by the kernel driver.
Parameter interestHandler: IOServiceInterestCallback used to process 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 command and doorbell handlers.
Returns: An IOUSBHostControllerInterface. The object is to be released by the caller.
§Safety
queuepossibly has additional threading requirements.command_handlermust be a valid pointer.doorbell_handlermust be a valid pointer.interest_handlermust be implemented correctly.
Sourcepub unsafe fn destroy(&self)
pub unsafe fn destroy(&self)
Removes underlying allocations of the IOUSBHostControllerInterface object along with user client
When the IOUSBHostControllerInterface 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 freed, destroy will be called automatically. Calling destroy multiple times has no effect.
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 for asynchronous operations.
Sourcepub unsafe fn enqueueInterrupt_error(
&self,
interrupt: NonNull<IOUSBHostCIMessage>,
) -> Result<(), Retained<NSError>>
Available on crate feature IOUSBHostControllerInterfaceDefinitions only.
pub unsafe fn enqueueInterrupt_error( &self, interrupt: NonNull<IOUSBHostCIMessage>, ) -> Result<(), Retained<NSError>>
IOUSBHostControllerInterfaceDefinitions only.Enqueue an interrupt for delivery to the kernel service
This method enqueues one interrupt message for delivery to the kernel service. interruptRateHz is used to determine when the interrupt message is delivered to the kernel service.
Parameter interrupt: An IOUSBHostCIMessage structure representing an interrupt message
§Safety
interrupt must be a valid pointer.
Sourcepub unsafe fn enqueueInterrupt_expedite_error(
&self,
interrupt: NonNull<IOUSBHostCIMessage>,
expedite: bool,
) -> Result<(), Retained<NSError>>
Available on crate feature IOUSBHostControllerInterfaceDefinitions only.
pub unsafe fn enqueueInterrupt_expedite_error( &self, interrupt: NonNull<IOUSBHostCIMessage>, expedite: bool, ) -> Result<(), Retained<NSError>>
IOUSBHostControllerInterfaceDefinitions only.Enqueue an interrupt for delivery to the kernel service
This method enqueues one interrupt message for delivery to the kernel service.
Parameter interrupt: An IOUSBHostCIMessage structure representing an interrupt message
Parameter expedite: Bool NO to use interruptRateHz to determine when the interrupt message is delivered to the kernel service. Bool YES if interruptRateHz
should be ignored, sending the message to the kernel driver at the next opportunity while maintaining in-order delivery of all interrupt messages.
§Safety
interrupt must be a valid pointer.
Sourcepub unsafe fn enqueueInterrupts_count_error(
&self,
interrupts: NonNull<IOUSBHostCIMessage>,
count: NSUInteger,
) -> Result<(), Retained<NSError>>
Available on crate feature IOUSBHostControllerInterfaceDefinitions only.
pub unsafe fn enqueueInterrupts_count_error( &self, interrupts: NonNull<IOUSBHostCIMessage>, count: NSUInteger, ) -> Result<(), Retained<NSError>>
IOUSBHostControllerInterfaceDefinitions only.Enqueue interrupts for delivery to the kernel service
This method enqueues one or more interrupt messages for delivery to the kernel service. interruptRateHz is used to determine when the interrupt message is delivered to the kernel service.
Parameter interrupts: An IOUSBHostCIMessage structure representing one or more interrupt messages
Parameter count: The number of interrupt messages represented by the interrupts parameter
§Safety
interrupts must be a valid pointer.
Sourcepub unsafe fn enqueueInterrupts_count_expedite_error(
&self,
interrupts: NonNull<IOUSBHostCIMessage>,
count: NSUInteger,
expedite: bool,
) -> Result<(), Retained<NSError>>
Available on crate feature IOUSBHostControllerInterfaceDefinitions only.
pub unsafe fn enqueueInterrupts_count_expedite_error( &self, interrupts: NonNull<IOUSBHostCIMessage>, count: NSUInteger, expedite: bool, ) -> Result<(), Retained<NSError>>
IOUSBHostControllerInterfaceDefinitions only.Enqueue interrupts for delivery to the kernel service
This method enqueues one or more interrupt messages for delivery to the kernel service. interruptRateHz is used to determine when the interrupt message is delivered to the kernel service.
Parameter interrupts: An IOUSBHostCIMessage structure representing one or more interrupt messages
Parameter count: The number of interrupt messages represented by the interrupts parameter
Parameter expedite: Bool NO to use interruptRateHz to determine when the interrupt message is delivered to the kernel service. Bool YES if interruptRateHz
should be ignored, sending the message to the kernel driver at the next opportunity while maintaining in-order delivery of all interrupt messages.
§Safety
interrupts must be a valid pointer.
Sourcepub unsafe fn interruptRateHz(&self) -> NSUInteger
pub unsafe fn interruptRateHz(&self) -> NSUInteger
The interrupt moderation rate for sending interrupt messages to the kernel driver
interruptRateHz will cause submitted interrupt messages to be batched together and submitted to the kernel at the specified rate. A value ot 0 will deliver all interrupts to the kernel driver as soon as possible.
Sourcepub unsafe fn setInterruptRateHz(&self, interrupt_rate_hz: NSUInteger)
pub unsafe fn setInterruptRateHz(&self, interrupt_rate_hz: NSUInteger)
Setter for interruptRateHz.
Sourcepub unsafe fn descriptionForMessage(
&self,
message: NonNull<IOUSBHostCIMessage>,
) -> Retained<NSString>
Available on crate feature IOUSBHostControllerInterfaceDefinitions only.
pub unsafe fn descriptionForMessage( &self, message: NonNull<IOUSBHostCIMessage>, ) -> Retained<NSString>
IOUSBHostControllerInterfaceDefinitions only.§Safety
message must be a valid pointer.
pub unsafe fn controllerStateMachine( &self, ) -> Retained<IOUSBHostCIControllerStateMachine>
IOUSBHostCIControllerStateMachine only.Sourcepub unsafe fn getPortStateMachineForCommand_error(
&self,
command: NonNull<IOUSBHostCIMessage>,
) -> Result<Retained<IOUSBHostCIPortStateMachine>, Retained<NSError>>
Available on crate features IOUSBHostCIPortStateMachine and IOUSBHostControllerInterfaceDefinitions only.
pub unsafe fn getPortStateMachineForCommand_error( &self, command: NonNull<IOUSBHostCIMessage>, ) -> Result<Retained<IOUSBHostCIPortStateMachine>, Retained<NSError>>
IOUSBHostCIPortStateMachine and IOUSBHostControllerInterfaceDefinitions only.§Safety
command must be a valid pointer.
pub unsafe fn getPortStateMachineForPort_error( &self, port: NSUInteger, ) -> Result<Retained<IOUSBHostCIPortStateMachine>, Retained<NSError>>
IOUSBHostCIPortStateMachine only.Sourcepub unsafe fn capabilities(&self) -> NonNull<IOUSBHostCIMessage>
Available on crate feature IOUSBHostControllerInterfaceDefinitions only.
pub unsafe fn capabilities(&self) -> NonNull<IOUSBHostCIMessage>
IOUSBHostControllerInterfaceDefinitions only.The capabilities structure passed in during initialization
The capabilities passed into the initializer can be retrieved for reference.
Sourcepub unsafe fn capabilitiesForPort(
&self,
port: NSUInteger,
) -> NonNull<IOUSBHostCIMessage>
Available on crate feature IOUSBHostControllerInterfaceDefinitions only.
pub unsafe fn capabilitiesForPort( &self, port: NSUInteger, ) -> NonNull<IOUSBHostCIMessage>
IOUSBHostControllerInterfaceDefinitions only.Retrieve a port capabilities structure passed in during initialization
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<NSObject> for IOUSBHostControllerInterface
impl AsRef<NSObject> for IOUSBHostControllerInterface
Source§impl ClassType for IOUSBHostControllerInterface
impl ClassType for IOUSBHostControllerInterface
Source§const NAME: &'static str = "IOUSBHostControllerInterface"
const NAME: &'static str = "IOUSBHostControllerInterface"
Source§type ThreadKind = <<IOUSBHostControllerInterface as ClassType>::Super as ClassType>::ThreadKind
type ThreadKind = <<IOUSBHostControllerInterface as ClassType>::Super as ClassType>::ThreadKind
Source§impl Debug for IOUSBHostControllerInterface
impl Debug for IOUSBHostControllerInterface
Source§impl Deref for IOUSBHostControllerInterface
impl Deref for IOUSBHostControllerInterface
Source§impl Hash for IOUSBHostControllerInterface
impl Hash for IOUSBHostControllerInterface
Source§impl NSObjectProtocol for IOUSBHostControllerInterface
impl NSObjectProtocol for IOUSBHostControllerInterface
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