objc2_io_usb_host/generated/IOUSBHostCIDeviceStateMachine.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 device
11 ///
12 /// This class assists with tracking internal state transitions of a user-mode USB host controller device, and parses IOUSBHostCIMessage command
13 /// structures to update state and generate properly formatted command responses. Clients should create an IOUSBHostCIDeviceStateMachine in
14 /// response to an IOUSBHostCIMessageTypeDeviceCreate command, and then use the provided interfaces to identify and process commands
15 /// for the device. The IOUSBHostCIDeviceStateMachine should be destroyed in response to an IOUSBHostCIMessageTypeDeviceDestroy command.
16 ///
17 /// IOUSBHostCIDeviceStateMachine does not provide any concurrency protection, the client is responsible for necessary serialization.
18 ///
19 /// See also [Apple's documentation](https://developer.apple.com/documentation/iousbhost/iousbhostcidevicestatemachine?language=objc)
20 #[unsafe(super(NSObject))]
21 #[derive(Debug, PartialEq, Eq, Hash)]
22 pub struct IOUSBHostCIDeviceStateMachine;
23);
24
25extern_conformance!(
26 unsafe impl NSObjectProtocol for IOUSBHostCIDeviceStateMachine {}
27);
28
29impl IOUSBHostCIDeviceStateMachine {
30 extern_methods!(
31 #[unsafe(method(init))]
32 #[unsafe(method_family = init)]
33 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
34
35 #[cfg(all(
36 feature = "IOUSBHostControllerInterface",
37 feature = "IOUSBHostControllerInterfaceDefinitions"
38 ))]
39 /// Initializes an IOUSBHostCIDeviceStateMachine object
40 ///
41 /// The IOUSBHostCIDeviceStateMachine defaults to the IOUSBHostCIDeviceStateActive state.
42 ///
43 /// Parameter `interface`: IOUSBHostControllerInterface which will be used to send command responses.
44 ///
45 /// Parameter `command`: IOUSBHostCIMessage with type IOUSBHostCIMessageTypeDeviceCreate
46 ///
47 /// Returns: IOUSBHostCIDeviceStateMachine instance, to be released by the caller.
48 ///
49 /// # Safety
50 ///
51 /// `command` must be a valid pointer.
52 #[unsafe(method(initWithInterface:command:error:_))]
53 #[unsafe(method_family = init)]
54 pub unsafe fn initWithInterface_command_error(
55 this: Allocated<Self>,
56 interface: &IOUSBHostControllerInterface,
57 command: NonNull<IOUSBHostCIMessage>,
58 ) -> Result<Retained<Self>, Retained<NSError>>;
59
60 #[cfg(feature = "IOUSBHostControllerInterfaceDefinitions")]
61 /// Inspect an IOUSBHostCIMessage command
62 ///
63 /// The IOUSBHostCIMessage command is inspected to determine if it is handled by the state machine, and
64 /// is appropriate for the current state.
65 ///
66 /// Parameter `command`: IOUSBHostCIMessage command structure received from the kernel driver.
67 ///
68 /// Returns: BOOL YES if the command is targeting a controller, and can be handled in the current state
69 /// BOOL NO if the command does not target a controller, or cannot be handled in the current state
70 ///
71 /// # Safety
72 ///
73 /// `command` must be a valid pointer.
74 #[unsafe(method(inspectCommand:error:_))]
75 #[unsafe(method_family = none)]
76 pub unsafe fn inspectCommand_error(
77 &self,
78 command: NonNull<IOUSBHostCIMessage>,
79 ) -> Result<(), Retained<NSError>>;
80
81 #[cfg(feature = "IOUSBHostControllerInterfaceDefinitions")]
82 /// Advance the state machine and respond to an IOUSBHostCIMessage command
83 ///
84 /// If the command passes inspectCommand and the client indicates the command was processed successfully, the state machine is
85 /// advanced, and a properly formatted command response message is sent to the kernel driver. If the client indicates the command was
86 /// not processed successfully, the state machine is not advanced but a properly formatted command response message is sent to the kernel
87 /// driver.
88 ///
89 /// Parameter `command`: IOUSBHostCIMessage command structure received from the kernel driver.
90 ///
91 /// Parameter `status`: IOUSBHostCIMessageStatus reported by the user-mode USB host controller implementation for the command response.
92 ///
93 /// Returns: BOOL YES if the command response was sent to the kernel driver
94 /// BOOL NO if the command response was not sent to the kernel driver
95 ///
96 /// # Safety
97 ///
98 /// `command` must be a valid pointer.
99 #[unsafe(method(respondToCommand:status:error:_))]
100 #[unsafe(method_family = none)]
101 pub unsafe fn respondToCommand_status_error(
102 &self,
103 command: NonNull<IOUSBHostCIMessage>,
104 status: IOUSBHostCIMessageStatus,
105 ) -> Result<(), Retained<NSError>>;
106
107 #[cfg(feature = "IOUSBHostControllerInterfaceDefinitions")]
108 /// Advance the state machine and respond to an IOUSBHostCIMessageTypeDeviceCreate command
109 ///
110 /// If the command passes inspectCommand and the client indicates the command was processed successfully, the state machine is
111 /// advanced, and a properly formatted command response message is sent to the kernel driver. If the client indicates the command was
112 /// not processed successfully, the state machine is not advanced but a properly formatted command response message is sent to the kernel
113 /// driver.
114 ///
115 /// Parameter `command`: IOUSBHostCIMessage command structure received from the kernel driver. The Type field must be IOUSBHostCIMessageTypeDeviceCreate
116 ///
117 /// Parameter `status`: IOUSBHostCIMessageStatus reported by the user-mode USB host controller implementation for the command response.
118 ///
119 /// Parameter `deviceAddress`: NSUInteger used only when responding to the initial IOUSBHostCIMessageTypeDeviceCreate command, containing
120 /// a valid USB device address successfully assigned to the device.
121 ///
122 /// Returns: BOOL YES if the command response was sent to the kernel driver
123 /// BOOL NO if the command response was not sent to the kernel driver
124 ///
125 /// # Safety
126 ///
127 /// `command` must be a valid pointer.
128 #[unsafe(method(respondToCommand:status:deviceAddress:error:_))]
129 #[unsafe(method_family = none)]
130 pub unsafe fn respondToCommand_status_deviceAddress_error(
131 &self,
132 command: NonNull<IOUSBHostCIMessage>,
133 status: IOUSBHostCIMessageStatus,
134 device_address: NSUInteger,
135 ) -> Result<(), Retained<NSError>>;
136
137 #[cfg(feature = "IOUSBHostControllerInterfaceDefinitions")]
138 #[unsafe(method(deviceState))]
139 #[unsafe(method_family = none)]
140 pub unsafe fn deviceState(&self) -> IOUSBHostCIDeviceState;
141
142 #[unsafe(method(completeRoute))]
143 #[unsafe(method_family = none)]
144 pub unsafe fn completeRoute(&self) -> NSUInteger;
145
146 #[unsafe(method(deviceAddress))]
147 #[unsafe(method_family = none)]
148 pub unsafe fn deviceAddress(&self) -> NSUInteger;
149
150 #[cfg(feature = "IOUSBHostControllerInterface")]
151 #[unsafe(method(controllerInterface))]
152 #[unsafe(method_family = none)]
153 pub unsafe fn controllerInterface(&self) -> Retained<IOUSBHostControllerInterface>;
154 );
155}
156
157/// Methods declared on superclass `NSObject`.
158impl IOUSBHostCIDeviceStateMachine {
159 extern_methods!(
160 #[unsafe(method(new))]
161 #[unsafe(method_family = new)]
162 pub unsafe fn new() -> Retained<Self>;
163 );
164}