objc2_io_usb_host/generated/
IOUSBHostCIControllerStateMachine.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4use objc2::__framework_prelude::*;
5use objc2_foundation::*;
6
7use crate::*;
8
9extern_class!(
10    /// The object representing the state of a user-mode USB host controller
11    ///
12    /// This class assists with tracking internal state transitions of a user-mode USB host controller, and parses IOUSBHostCIMessage command
13    /// structures to update state and generate properly formatted command responses.
14    ///
15    /// IOUSBHostCIControllerStateMachine does not provide any concurrency protection, the client is responsible for necessary serialization.
16    ///
17    /// See also [Apple's documentation](https://developer.apple.com/documentation/iousbhost/iousbhostcicontrollerstatemachine?language=objc)
18    #[unsafe(super(NSObject))]
19    #[derive(Debug, PartialEq, Eq, Hash)]
20    pub struct IOUSBHostCIControllerStateMachine;
21);
22
23extern_conformance!(
24    unsafe impl NSObjectProtocol for IOUSBHostCIControllerStateMachine {}
25);
26
27impl IOUSBHostCIControllerStateMachine {
28    extern_methods!(
29        #[unsafe(method(init))]
30        #[unsafe(method_family = init)]
31        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
32
33        #[cfg(feature = "IOUSBHostControllerInterface")]
34        /// Initializes an IOUSBHostCIControllerStateMachine object
35        ///
36        /// The IOUSBHostCIControllerStateMachine defaults to the IOUSBHostCIControllerStateOff state.
37        ///
38        /// Parameter `interface`: IOUSBHostControllerInterface which will be used to send command responses.
39        ///
40        /// Returns: IOUSBHostCIControllerStateMachine instance, to be released by the caller.
41        #[unsafe(method(initWithInterface:error:_))]
42        #[unsafe(method_family = init)]
43        pub unsafe fn initWithInterface_error(
44            this: Allocated<Self>,
45            interface: &IOUSBHostControllerInterface,
46        ) -> Result<Retained<Self>, Retained<NSError>>;
47
48        #[cfg(feature = "IOUSBHostControllerInterfaceDefinitions")]
49        /// Inspect an IOUSBHostCIMessage command
50        ///
51        /// The IOUSBHostCIMessage command is inspected to determine if it is handled by the state machine, and
52        /// is appropriate for the current state.
53        ///
54        /// Parameter `command`: IOUSBHostCIMessage command structure received from the kernel driver.
55        ///
56        /// Returns: BOOL YES if the command is targeting a controller, and can be handled in the current state
57        /// BOOL NO if the command does not target a controller, or cannot be handled in the current state
58        ///
59        /// # Safety
60        ///
61        /// `command` must be a valid pointer.
62        #[unsafe(method(inspectCommand:error:_))]
63        #[unsafe(method_family = none)]
64        pub unsafe fn inspectCommand_error(
65            &self,
66            command: NonNull<IOUSBHostCIMessage>,
67        ) -> Result<(), Retained<NSError>>;
68
69        #[cfg(feature = "IOUSBHostControllerInterfaceDefinitions")]
70        /// Advance the state machine and respond to an IOUSBHostCIMessage command
71        ///
72        /// If the command passes inspectCommand and the client indicates the command was processed successfully, the state machine is
73        /// advanced, and a properly formatted command response message is sent to the kernel driver.  If the client indicates the command was
74        /// not processed successfully, the state machine is not advanced but a properly formatted command response message is sent to the kernel
75        /// driver.
76        ///
77        /// Parameter `command`: IOUSBHostCIMessage command structure received from the kernel driver.
78        ///
79        /// Parameter `status`: IOUSBHostCIMessageStatus reported by the user-mode USB host controller implementation for the command response.
80        ///
81        /// Returns: BOOL YES if the command response was sent to the kernel driver
82        /// BOOL NO if the command response was not sent to the kernel driver
83        ///
84        /// # Safety
85        ///
86        /// `command` must be a valid pointer.
87        #[unsafe(method(respondToCommand:status:error:_))]
88        #[unsafe(method_family = none)]
89        pub unsafe fn respondToCommand_status_error(
90            &self,
91            command: NonNull<IOUSBHostCIMessage>,
92            status: IOUSBHostCIMessageStatus,
93        ) -> Result<(), Retained<NSError>>;
94
95        #[cfg(feature = "IOUSBHostControllerInterfaceDefinitions")]
96        /// Advance the state machine and respond to an IOUSBHostCIMessageTypeControllerFrameNumber command
97        ///
98        /// If the command passes inspectCommand and the client indicates the command was processed successfully, enqueueUpdatedFrame:timestamp:error
99        /// is called with the supplied parameters, and a properly formatted command response message is sent to the kernel driver.  If the client
100        /// indicates the command was not processed successfully, enqueueUpdatedFrame:timestamp:error is not called but a properly formatted
101        /// command response message is sent to the kernel driver.
102        ///
103        /// Parameter `command`: IOUSBHostCIMessage command structure received from the kernel driver.  The Type field must be IOUSBHostCIMessageTypeControllerFrameNumber
104        ///
105        /// Parameter `status`: IOUSBHostCIMessageStatus reported by the user-mode USB host controller implementation for the command response.
106        ///
107        /// Parameter `frame`: uint64_t containing the number of 1ms frames that have elapsed since the controller began counting frames
108        ///
109        /// Parameter `timestamp`: uint64_t containing the mach_absolute_time() correlated to the beginning of the frameNumber
110        ///
111        /// Returns: BOOL YES if the command response was sent to the kernel driver
112        /// BOOL NO if the command response was not sent to the kernel driver
113        ///
114        /// # Safety
115        ///
116        /// `command` must be a valid pointer.
117        #[unsafe(method(respondToCommand:status:frame:timestamp:error:_))]
118        #[unsafe(method_family = none)]
119        pub unsafe fn respondToCommand_status_frame_timestamp_error(
120            &self,
121            command: NonNull<IOUSBHostCIMessage>,
122            status: IOUSBHostCIMessageStatus,
123            frame: u64,
124            timestamp: u64,
125        ) -> Result<(), Retained<NSError>>;
126
127        /// Enqueue frame and timestamp messages for delivery to the kernel driver
128        ///
129        /// If the controller interface is in the IOUSBHostCIControllerStateActive state, messages with the type IOUSBHostCIMessageTypeFrameNumberUpdate and
130        /// IOUSBHostCIMessageTypeFrameTimestampUpdate will be generated using the provided inputs, and enqueued for delivery to the kernel driver.
131        /// The frame and timestamp information provided effectively measure the duration of the controller's 1ms frame in terms of system time.  A 1% frame duration
132        /// variation is permitted.  A larger frame duration variation will result in a IOUSBHostCIExceptionTypeFrameUpdateError.
133        ///
134        /// Parameter `frame`: uint64_t containing the number of 1ms frames that have elapsed since the controller began counting frames
135        ///
136        /// Parameter `timestamp`: uint64_t containing the mach_absolute_time() correlated to the beginning of the frameNumber
137        ///
138        /// Returns: BOOL YES if the messages were enqueued for delivery to the kernel.
139        /// BOOL NO if the messages were not enqueued for delivery to the kernel.
140        #[unsafe(method(enqueueUpdatedFrame:timestamp:error:_))]
141        #[unsafe(method_family = none)]
142        pub unsafe fn enqueueUpdatedFrame_timestamp_error(
143            &self,
144            frame: u64,
145            timestamp: u64,
146        ) -> Result<(), Retained<NSError>>;
147
148        #[cfg(feature = "IOUSBHostControllerInterfaceDefinitions")]
149        #[unsafe(method(controllerState))]
150        #[unsafe(method_family = none)]
151        pub unsafe fn controllerState(&self) -> IOUSBHostCIControllerState;
152
153        #[cfg(feature = "IOUSBHostControllerInterface")]
154        #[unsafe(method(controllerInterface))]
155        #[unsafe(method_family = none)]
156        pub unsafe fn controllerInterface(&self) -> Retained<IOUSBHostControllerInterface>;
157    );
158}
159
160/// Methods declared on superclass `NSObject`.
161impl IOUSBHostCIControllerStateMachine {
162    extern_methods!(
163        #[unsafe(method(new))]
164        #[unsafe(method_family = new)]
165        pub unsafe fn new() -> Retained<Self>;
166    );
167}