pub struct IOHIDTransaction { /* private fields */ }hid only.Expand description
This is the type of a reference to the IOHIDTransaction.
See also Apple’s documentation
Implementations§
Source§impl IOHIDTransaction
impl IOHIDTransaction
Sourcepub fn new(
allocator: Option<&CFAllocator>,
device: &IOHIDDevice,
direction: IOHIDTransactionDirectionType,
options: IOOptionBits,
) -> Option<CFRetained<IOHIDTransaction>>
pub fn new( allocator: Option<&CFAllocator>, device: &IOHIDDevice, direction: IOHIDTransactionDirectionType, options: IOOptionBits, ) -> Option<CFRetained<IOHIDTransaction>>
Creates an IOHIDTransaction object for the specified device.
IOHIDTransaction objects can be used to either send or receive multiple element values. As such the direction used should represent they type of objects added to the transaction.
Parameter allocator: Allocator to be used during creation.
Parameter device: IOHIDDevice object
Parameter direction: The direction, either in or out, for the transaction.
Parameter options: Reserved for future use.
Returns: Returns a new IOHIDTransactionRef.
Sourcepub fn device(&self) -> CFRetained<IOHIDDevice>
pub fn device(&self) -> CFRetained<IOHIDDevice>
Obtain the device associated with the transaction.
Parameter transaction: IOHIDTransaction to be queried.
Returns: Returns the a reference to the device.
Sourcepub fn direction(&self) -> IOHIDTransactionDirectionType
pub fn direction(&self) -> IOHIDTransactionDirectionType
Obtain the direction of the transaction.
Parameter transaction: IOHIDTransaction to be queried.
Returns: Returns the transaction direction.
Sourcepub fn set_direction(&self, direction: IOHIDTransactionDirectionType)
pub fn set_direction(&self, direction: IOHIDTransactionDirectionType)
Sets the direction of the transaction
This method is useful for manipulating bi-direction (feature) elements such that you can set or get element values without creating an additional transaction object.
Parameter transaction: IOHIDTransaction object to be modified.
Parameter direction: The new transaction direction.
Sourcepub fn add_element(&self, element: &IOHIDElement)
pub fn add_element(&self, element: &IOHIDElement)
Adds an element to the transaction
To minimize device traffic it is important to add elements that share a common report type and report id.
Parameter transaction: IOHIDTransaction object to be modified.
Parameter element: Element to be added to the transaction.
Sourcepub fn remove_element(&self, element: &IOHIDElement)
pub fn remove_element(&self, element: &IOHIDElement)
Removes an element to the transaction
Parameter transaction: IOHIDTransaction object to be modified.
Parameter element: Element to be removed to the transaction.
Sourcepub fn contains_element(&self, element: &IOHIDElement) -> bool
pub fn contains_element(&self, element: &IOHIDElement) -> bool
Queries the transaction to determine if elemement has been added.
Parameter transaction: IOHIDTransaction object to be queried.
Parameter element: Element to be queried.
Returns: Returns true or false depending if element is present.
Sourcepub unsafe fn schedule_with_run_loop(
&self,
run_loop: &CFRunLoop,
run_loop_mode: &CFString,
)
pub unsafe fn schedule_with_run_loop( &self, run_loop: &CFRunLoop, run_loop_mode: &CFString, )
Schedules transaction with run loop.
Formally associates transaction with client’s run loop. Scheduling this transaction with the run loop is necessary before making use of any asynchronous APIs.
Parameter transaction: IOHIDTransaction object to be modified.
Parameter runLoop: RunLoop to be used when scheduling any asynchronous
activity.
Parameter runLoopMode: Run loop mode to be used when scheduling any
asynchronous activity.
§Safety
run_loop possibly has additional threading requirements.
Sourcepub unsafe fn unschedule_from_run_loop(
&self,
run_loop: &CFRunLoop,
run_loop_mode: &CFString,
)
pub unsafe fn unschedule_from_run_loop( &self, run_loop: &CFRunLoop, run_loop_mode: &CFString, )
Unschedules transaction with run loop.
Formally disassociates transaction with client’s run loop.
Parameter transaction: IOHIDTransaction object to be modified.
Parameter runLoop: RunLoop to be used when scheduling any asynchronous
activity.
Parameter runLoopMode: Run loop mode to be used when scheduling any
asynchronous activity.
§Safety
run_loop possibly has additional threading requirements.
Sourcepub fn set_value(
&self,
element: &IOHIDElement,
value: &IOHIDValue,
options: IOOptionBits,
)
pub fn set_value( &self, element: &IOHIDElement, value: &IOHIDValue, options: IOOptionBits, )
Sets the value for a transaction element.
The value set is pended until the transaction is committed and is only used if the transaction direction is kIOHIDTransactionDirectionTypeOutput. Use the kIOHIDTransactionOptionDefaultOutputValue option to set the default element value.
Parameter transaction: IOHIDTransaction object to be modified.
Parameter element: Element to be modified after a commit.
Parameter value: Value to be set for the given element.
Parameter options: See IOHIDTransactionOption.
Sourcepub fn value(
&self,
element: &IOHIDElement,
options: IOOptionBits,
) -> Option<CFRetained<IOHIDValue>>
pub fn value( &self, element: &IOHIDElement, options: IOOptionBits, ) -> Option<CFRetained<IOHIDValue>>
Obtains the value for a transaction element.
If the transaction direction is kIOHIDTransactionDirectionTypeInput the value represents what was obtained from the device from the transaction. Otherwise, if the transaction direction is kIOHIDTransactionDirectionTypeOutput the value represents the pending value to be sent to the device. Use the kIOHIDTransactionOptionDefaultOutputValue option to get the default element value.
Parameter transaction: IOHIDTransaction object to be queried.
Parameter element: Element to be queried.
Parameter options: See IOHIDTransactionOption.
Returns: Returns IOHIDValueRef for the given element.
Sourcepub fn commit(&self) -> IOReturn
pub fn commit(&self) -> IOReturn
Synchronously commits element transaction to the device.
Parameter transaction: IOHIDTransaction object to be modified.
Returns: Returns kIOReturnSuccess if successful or a kern_return_t if unsuccessful.
Sourcepub unsafe fn commit_with_callback(
&self,
timeout: CFTimeInterval,
callback: IOHIDCallback,
context: *mut c_void,
) -> IOReturn
pub unsafe fn commit_with_callback( &self, timeout: CFTimeInterval, callback: IOHIDCallback, context: *mut c_void, ) -> IOReturn
Asynchronously commits element transaction to the device.
It is possible for elements from different reports to be present in a given transaction causing a commit to transcend multiple reports. Keep this in mind when setting a appropriate timeout.
Parameter transaction: IOHIDTransaction object to be modified.
Parameter timeout: Timeout in milliseconds for the transaction.
Parameter callback: Callback of type IOHIDCallback to be used when
transaction has been completed. If null, this method will
behave synchronously.
Parameter context: Pointer to data to be passed to the callback.
Returns: Returns kIOReturnSuccess if successful or a kern_return_t if unsuccessful.
§Safety
callbackmust be implemented correctly.contextmust be a valid pointer or null.
Methods from Deref<Target = CFType>§
Sourcepub fn downcast_ref<T>(&self) -> Option<&T>where
T: ConcreteType,
pub fn downcast_ref<T>(&self) -> Option<&T>where
T: ConcreteType,
Attempt to downcast the type to that of type T.
This is the reference-variant. Use CFRetained::downcast if you
want to convert a retained type. See also ConcreteType for more
details on which types support being converted to.
Sourcepub fn retain_count(&self) -> usize
pub fn retain_count(&self) -> usize
Get the reference count of the object.
This function may be useful for debugging. You normally do not use this function otherwise.
Beware that some things (like CFNumbers, small CFStrings etc.) may
not have a normal retain count for optimization purposes, and can
return usize::MAX in that case.
Trait Implementations§
Source§impl AsRef<AnyObject> for IOHIDTransaction
impl AsRef<AnyObject> for IOHIDTransaction
Source§impl AsRef<CFType> for IOHIDTransaction
impl AsRef<CFType> for IOHIDTransaction
Source§impl AsRef<IOHIDTransaction> for IOHIDTransaction
impl AsRef<IOHIDTransaction> for IOHIDTransaction
Source§impl Borrow<AnyObject> for IOHIDTransaction
impl Borrow<AnyObject> for IOHIDTransaction
Source§impl Borrow<CFType> for IOHIDTransaction
impl Borrow<CFType> for IOHIDTransaction
Source§impl ConcreteType for IOHIDTransaction
impl ConcreteType for IOHIDTransaction
Source§impl Debug for IOHIDTransaction
impl Debug for IOHIDTransaction
Source§impl Deref for IOHIDTransaction
impl Deref for IOHIDTransaction
Source§impl Hash for IOHIDTransaction
impl Hash for IOHIDTransaction
Source§impl Message for IOHIDTransaction
impl Message for IOHIDTransaction
Source§impl PartialEq for IOHIDTransaction
impl PartialEq for IOHIDTransaction
Source§impl RefEncode for IOHIDTransaction
impl RefEncode for IOHIDTransaction
Source§const ENCODING_REF: Encoding
const ENCODING_REF: Encoding
Source§impl Type for IOHIDTransaction
impl Type for IOHIDTransaction
Source§fn retain(&self) -> CFRetained<Self>where
Self: Sized,
fn retain(&self) -> CFRetained<Self>where
Self: Sized,
Source§fn as_concrete_TypeRef(&self) -> &Self
fn as_concrete_TypeRef(&self) -> &Self
core-foundation crate.Source§unsafe fn wrap_under_get_rule(ptr: *const Self) -> CFRetained<Self>where
Self: Sized,
unsafe fn wrap_under_get_rule(ptr: *const Self) -> CFRetained<Self>where
Self: Sized,
core-foundation crate. Read moreSource§fn as_CFTypeRef(&self) -> &CFType
fn as_CFTypeRef(&self) -> &CFType
core-foundation crate.Source§unsafe fn wrap_under_create_rule(ptr: *const Self) -> CFRetained<Self>where
Self: Sized,
unsafe fn wrap_under_create_rule(ptr: *const Self) -> CFRetained<Self>where
Self: Sized,
core-foundation crate. Read more