objc2_io_usb_host/generated/IOUSBHostCIPortStateMachine.rs
1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10extern_class!(
11 /// The object representing the state of a user-mode USB host controller root port
12 ///
13 /// This class assists with tracking internal state transitions of a user-mode USB host controller root port, and parses IOUSBHostCIMessage command
14 /// structures to update state and generate properly formatted command responses.
15 ///
16 /// IOUSBHostCIPortStateMachine does not provide any concurrency protection, the client is responsible for necessary serialization.
17 ///
18 /// See also [Apple's documentation](https://developer.apple.com/documentation/iousbhost/iousbhostciportstatemachine?language=objc)
19 #[unsafe(super(NSObject))]
20 #[derive(Debug, PartialEq, Eq, Hash)]
21 pub struct IOUSBHostCIPortStateMachine;
22);
23
24extern_conformance!(
25 unsafe impl NSObjectProtocol for IOUSBHostCIPortStateMachine {}
26);
27
28impl IOUSBHostCIPortStateMachine {
29 extern_methods!(
30 #[unsafe(method(init))]
31 #[unsafe(method_family = init)]
32 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
33
34 #[cfg(feature = "IOUSBHostControllerInterface")]
35 /// Initializes an IOUSBHostCIPortStateMachine object
36 ///
37 /// The IOUSBHostCIPortStateMachine defaults to the IOUSBHostCIPortStateOff state.
38 ///
39 /// Parameter `interface`: IOUSBHostControllerInterface which will be used to send command responses.
40 ///
41 /// Parameter `portNumber`: NSUInteger for the root port number tracked by this instance
42 ///
43 /// Returns: IOUSBHostCIPortStateMachine instance, to be released by the caller.
44 #[unsafe(method(initWithInterface:portNumber:error:_))]
45 #[unsafe(method_family = init)]
46 pub unsafe fn initWithInterface_portNumber_error(
47 this: Allocated<Self>,
48 interface: &IOUSBHostControllerInterface,
49 port_number: NSUInteger,
50 ) -> Result<Retained<Self>, Retained<NSError>>;
51
52 #[cfg(feature = "IOUSBHostControllerInterfaceDefinitions")]
53 /// Inspect an IOUSBHostCIMessage command
54 ///
55 /// The IOUSBHostCIMessage command is inspected to determine if it is handled by the state machine, and
56 /// is appropriate for the current state.
57 ///
58 /// Parameter `command`: IOUSBHostCIMessage command structure received from the kernel driver.
59 ///
60 /// Returns: BOOL YES if the command is targeting a controller, and can be handled in the current state
61 /// BOOL NO if the command does not target a controller, or cannot be handled in the current state
62 ///
63 /// # Safety
64 ///
65 /// `command` must be a valid pointer.
66 #[unsafe(method(inspectCommand:error:_))]
67 #[unsafe(method_family = none)]
68 pub unsafe fn inspectCommand_error(
69 &self,
70 command: NonNull<IOUSBHostCIMessage>,
71 ) -> Result<(), Retained<NSError>>;
72
73 #[cfg(feature = "IOUSBHostControllerInterfaceDefinitions")]
74 /// Advance the state machine and respond to an IOUSBHostCIMessage command
75 ///
76 /// If the command passes inspectCommand and the client indicates the command was processed successfully, the state machine is
77 /// advanced, and a properly formatted command response message is sent to the kernel driver. If the client indicates the command was
78 /// not processed successfully, the state machine is not advanced but a properly formatted command response message is sent to the kernel
79 /// driver.
80 ///
81 /// Parameter `command`: IOUSBHostCIMessage command structure received from the kernel driver.
82 ///
83 /// Parameter `status`: IOUSBHostCIMessageStatus reported by the user-mode USB host controller implementation for the command response.
84 ///
85 /// Returns: BOOL YES if the command response was sent to the kernel driver
86 /// BOOL NO if the command response was not sent to the kernel driver
87 ///
88 /// # Safety
89 ///
90 /// `command` must be a valid pointer.
91 #[unsafe(method(respondToCommand:status:error:_))]
92 #[unsafe(method_family = none)]
93 pub unsafe fn respondToCommand_status_error(
94 &self,
95 command: NonNull<IOUSBHostCIMessage>,
96 status: IOUSBHostCIMessageStatus,
97 ) -> Result<(), Retained<NSError>>;
98
99 #[unsafe(method(portNumber))]
100 #[unsafe(method_family = none)]
101 pub unsafe fn portNumber(&self) -> NSUInteger;
102
103 #[cfg(feature = "IOUSBHostControllerInterfaceDefinitions")]
104 #[unsafe(method(portState))]
105 #[unsafe(method_family = none)]
106 pub unsafe fn portState(&self) -> IOUSBHostCIPortState;
107
108 #[cfg(feature = "IOUSBHostControllerInterfaceDefinitions")]
109 #[unsafe(method(portStatus))]
110 #[unsafe(method_family = none)]
111 pub unsafe fn portStatus(&self) -> IOUSBHostCIPortStatus;
112
113 #[cfg(feature = "IOUSBHostControllerInterface")]
114 #[unsafe(method(controllerInterface))]
115 #[unsafe(method_family = none)]
116 pub unsafe fn controllerInterface(&self) -> Retained<IOUSBHostControllerInterface>;
117
118 /// Set the powered state of the port
119 ///
120 /// Before a port can be used, it must be powered on via a IOUSBHostCIMessageTypePortPowerOn command. As part of successfully processing this command
121 /// the powered property must be set to YES. Similarly, successful processing of the IOUSBHostCIMessageTypePortPowerOff command must set the powered
122 /// property to NO.
123 #[unsafe(method(powered))]
124 #[unsafe(method_family = none)]
125 pub unsafe fn powered(&self) -> bool;
126
127 /// Setter for [`powered`][Self::powered].
128 #[unsafe(method(setPowered:))]
129 #[unsafe(method_family = none)]
130 pub unsafe fn setPowered(&self, powered: bool);
131
132 /// Set the connection state of the port
133 ///
134 /// The connected property cannot be set for an unpowered port, and will read back as NO, just at IOUSBHostCIPortStatusConnected in the port status will always
135 /// read as 0. For a powered port, writing to the connected property will set IOUSBHostCIPortStatusConnected to match the provided value, and if the
136 /// new value is different from the previous value an IOUSBHostCIMessageTypePortEvent message will be sent to the kernel with IOUSBHostCIPortStatusConnectChange
137 /// set.
138 #[unsafe(method(connected))]
139 #[unsafe(method_family = none)]
140 pub unsafe fn connected(&self) -> bool;
141
142 /// Setter for [`connected`][Self::connected].
143 #[unsafe(method(setConnected:))]
144 #[unsafe(method_family = none)]
145 pub unsafe fn setConnected(&self, connected: bool);
146
147 /// Set the overcurrent state of the port
148 ///
149 /// The overcurrent property cannot be set for an unpowered port, and will read back as NO, just as IOUSBHostCIPortStatusOvercurrent in the port status will always
150 /// read as 0. For a powered port, writing to the overcurrent property will set IOUSBHostCIPortStatusOvercurrent to match the provided value, and if the
151 /// new value is different from the previous value an IOUSBHostCIMessageTypePortEvent message will be sent to the kernel with IOUSBHostCIPortStatusOvercurrentChange
152 /// set.
153 #[unsafe(method(overcurrent))]
154 #[unsafe(method_family = none)]
155 pub unsafe fn overcurrent(&self) -> bool;
156
157 /// Setter for [`overcurrent`][Self::overcurrent].
158 #[unsafe(method(setOvercurrent:))]
159 #[unsafe(method_family = none)]
160 pub unsafe fn setOvercurrent(&self, overcurrent: bool);
161
162 #[cfg(feature = "IOUSBHostControllerInterfaceDefinitions")]
163 #[unsafe(method(updateLinkState:speed:inhibitLinkStateChange:error:_))]
164 #[unsafe(method_family = none)]
165 pub unsafe fn updateLinkState_speed_inhibitLinkStateChange_error(
166 &self,
167 link_state: IOUSBHostCILinkState,
168 speed: IOUSBHostCIDeviceSpeed,
169 inhibit_link_state_change: bool,
170 ) -> Result<(), Retained<NSError>>;
171
172 #[cfg(feature = "IOUSBHostControllerInterfaceDefinitions")]
173 #[unsafe(method(linkState))]
174 #[unsafe(method_family = none)]
175 pub unsafe fn linkState(&self) -> IOUSBHostCILinkState;
176
177 #[cfg(feature = "IOUSBHostControllerInterfaceDefinitions")]
178 #[unsafe(method(speed))]
179 #[unsafe(method_family = none)]
180 pub unsafe fn speed(&self) -> IOUSBHostCIDeviceSpeed;
181 );
182}
183
184/// Methods declared on superclass `NSObject`.
185impl IOUSBHostCIPortStateMachine {
186 extern_methods!(
187 #[unsafe(method(new))]
188 #[unsafe(method_family = new)]
189 pub unsafe fn new() -> Retained<Self>;
190 );
191}