objc2_io_usb_host/generated/
IOUSBHostCIEndpointStateMachine.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 endpoint
11    ///
12    /// This class assists with tracking internal state transitions of a user-mode USB host controller endpoint, and parses IOUSBHostCIMessage command
13    /// structures to update state and generate properly formatted command responses.  Clients should create an IOUSBHostCIEndpointStateMachine in
14    /// response to an IOUSBHostCIMessageTypeEndpointCreate command, and then use the provided interfaces to identify and process commands,
15    /// doorbells, and transfer structures for the endpoint.  The IOUSBHostCIEndpointStateMachine should be destroyed in response to an
16    /// IOUSBHostCIMessageTypeEndpointDestroy command.
17    ///
18    /// Endpoint state is controlled by IOUSBHostCIMessage structures representing commands and transfer completions, and IOUSBHostCIDoorbell messages.
19    /// Only an endpoint in the IOUSBHostCIEndpointStateActive state may inspect transfer structures, read or modify IO buffers, and generate transfer completions.
20    ///
21    /// IOUSBHostCIEndpointStateMachine does not provide any concurrency protection, the client is responsible for necessary serialization.
22    ///
23    /// See also [Apple's documentation](https://developer.apple.com/documentation/iousbhost/iousbhostciendpointstatemachine?language=objc)
24    #[unsafe(super(NSObject))]
25    #[derive(Debug, PartialEq, Eq, Hash)]
26    pub struct IOUSBHostCIEndpointStateMachine;
27);
28
29extern_conformance!(
30    unsafe impl NSObjectProtocol for IOUSBHostCIEndpointStateMachine {}
31);
32
33impl IOUSBHostCIEndpointStateMachine {
34    extern_methods!(
35        #[unsafe(method(init))]
36        #[unsafe(method_family = init)]
37        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
38
39        #[cfg(all(
40            feature = "IOUSBHostControllerInterface",
41            feature = "IOUSBHostControllerInterfaceDefinitions"
42        ))]
43        /// Initializes an IOUSBHostCIEndpointStateMachine object
44        ///
45        /// The IOUSBHostCIEndpointStateMachine defaults to the IOUSBHostCIEndpointStatePaused state.
46        ///
47        /// Parameter `interface`: IOUSBHostControllerInterface which will be used to send command responses.
48        ///
49        /// Parameter `command`: IOUSBHostCIMessage with type IOUSBHostCIMessageTypeEndpointCreate
50        ///
51        /// Returns: IOUSBHostCIEndpointStateMachine instance, to be released by the caller.
52        ///
53        /// # Safety
54        ///
55        /// `command` must be a valid pointer.
56        #[unsafe(method(initWithInterface:command:error:_))]
57        #[unsafe(method_family = init)]
58        pub unsafe fn initWithInterface_command_error(
59            this: Allocated<Self>,
60            interface: &IOUSBHostControllerInterface,
61            command: NonNull<IOUSBHostCIMessage>,
62        ) -> Result<Retained<Self>, Retained<NSError>>;
63
64        #[cfg(feature = "IOUSBHostControllerInterfaceDefinitions")]
65        /// Inspect an IOUSBHostCIMessage command
66        ///
67        /// The IOUSBHostCIMessage command is inspected to determine if it is handled by this state machine and is appropriate for the current state.
68        ///
69        /// Parameter `command`: IOUSBHostCIMessage command structure received from the kernel driver.
70        ///
71        /// Returns: BOOL YES if the command is targeting this endpoint, and can be handled in the current state
72        /// BOOL NO if the command does not target this endpoint, or cannot be handled in the current state
73        ///
74        /// # Safety
75        ///
76        /// `command` must be a valid pointer.
77        #[unsafe(method(inspectCommand:error:_))]
78        #[unsafe(method_family = none)]
79        pub unsafe fn inspectCommand_error(
80            &self,
81            command: NonNull<IOUSBHostCIMessage>,
82        ) -> Result<(), Retained<NSError>>;
83
84        #[cfg(feature = "IOUSBHostControllerInterfaceDefinitions")]
85        /// Advance the state machine and respond to an IOUSBHostCIMessage command
86        ///
87        /// If the command passes inspectCommand and the client indicates the command was processed successfully, endpointState is updated and
88        /// a properly formatted command response message is sent to the kernel driver.  If the client indicates the command was not processed successfully,
89        /// endpointState is not updated but a properly formatted command response message is sent to the kernel driver.
90        ///
91        /// Parameter `command`: IOUSBHostCIMessage command structure received from the kernel driver.
92        ///
93        /// Parameter `status`: IOUSBHostCIMessageStatus reported by the user-mode USB host controller implementation for the command response.
94        ///
95        /// Returns: BOOL YES if the command response was sent to the kernel driver
96        /// BOOL NO if the command response was not sent to the kernel driver
97        ///
98        /// # Safety
99        ///
100        /// `command` must be a valid pointer.
101        #[unsafe(method(respondToCommand:status:error:_))]
102        #[unsafe(method_family = none)]
103        pub unsafe fn respondToCommand_status_error(
104            &self,
105            command: NonNull<IOUSBHostCIMessage>,
106            status: IOUSBHostCIMessageStatus,
107        ) -> Result<(), Retained<NSError>>;
108
109        #[cfg(feature = "IOUSBHostControllerInterfaceDefinitions")]
110        /// Advance the state machine and process an IOUSBHostCIDoorbell message
111        ///
112        /// The IOUSBHostCIDoorbell is inspected to determine if it is handled by this state machine and is appropriate for the current state.  If successful,
113        /// the client should check for an IOUSBHostCIEndpointStateActive endpointState and a currentTransferMessage with IOUSBHostCIMessageControlValid set to determine
114        /// if more IOUSBHostCIMessages should be processed.
115        ///
116        /// Parameter `doorbell`: IOUSBHostCIDoorbell message received from the kernel driver.
117        ///
118        /// Returns: BOOL YES if the doorbell is targeting this endpoint and can be handled in the current state.
119        /// BOOL NO is the doorbell does not target this endpoint or cannot be handled in the current state.
120        #[unsafe(method(processDoorbell:error:_))]
121        #[unsafe(method_family = none)]
122        pub unsafe fn processDoorbell_error(
123            &self,
124            doorbell: IOUSBHostCIDoorbell,
125        ) -> Result<(), Retained<NSError>>;
126
127        #[cfg(feature = "IOUSBHostControllerInterfaceDefinitions")]
128        /// Send an IOUSBHostCIMessage representing a transfer completion to the kernel, and advance the state machine
129        ///
130        /// When a client has processed an IOUSBHostCIMessage representing a transfer, the result is reported to the kernel by another IOUSBHostCIMessage.  If successful,
131        /// this object will use controllerInterface's enqueueInterrupt interface to send a properly formatted IOUSBHostCIMessage to the kernel with
132        /// IOUSBHostCITransferCompletionMessageData1TransferStructure populated with currentTransferMessage's virtual address, and endpointState and currentTransferMessage
133        /// are updated.  After a successful call, the client should check for an IOUSBHostCIEndpointStateActive endpointState and a currentTransferMessage with IOUSBHostCIMessageControlValid
134        /// set to determine if more IOUSBHostCIMessages should be processed.
135        ///
136        /// Parameter `message`: pointer to the IOUSBHostCIMessage which generated this tranafer completion message.  This must match currentTransferMessage to be successful.
137        ///
138        /// Parameter `status`: IOUSBHostCIMessageStatus
139        ///
140        /// Parameter `transferLength`: The number of bytes transferred for the specified transfer structure.
141        ///
142        /// # Safety
143        ///
144        /// `message` must be a valid pointer.
145        #[unsafe(method(enqueueTransferCompletionForMessage:status:transferLength:error:_))]
146        #[unsafe(method_family = none)]
147        pub unsafe fn enqueueTransferCompletionForMessage_status_transferLength_error(
148            &self,
149            message: NonNull<IOUSBHostCIMessage>,
150            status: IOUSBHostCIMessageStatus,
151            transfer_length: NSUInteger,
152        ) -> Result<(), Retained<NSError>>;
153
154        #[cfg(feature = "IOUSBHostControllerInterfaceDefinitions")]
155        #[unsafe(method(endpointState))]
156        #[unsafe(method_family = none)]
157        pub unsafe fn endpointState(&self) -> IOUSBHostCIEndpointState;
158
159        #[unsafe(method(deviceAddress))]
160        #[unsafe(method_family = none)]
161        pub unsafe fn deviceAddress(&self) -> NSUInteger;
162
163        #[unsafe(method(endpointAddress))]
164        #[unsafe(method_family = none)]
165        pub unsafe fn endpointAddress(&self) -> NSUInteger;
166
167        #[cfg(feature = "IOUSBHostControllerInterfaceDefinitions")]
168        #[unsafe(method(currentTransferMessage))]
169        #[unsafe(method_family = none)]
170        pub unsafe fn currentTransferMessage(&self) -> NonNull<IOUSBHostCIMessage>;
171
172        #[cfg(feature = "IOUSBHostControllerInterface")]
173        #[unsafe(method(controllerInterface))]
174        #[unsafe(method_family = none)]
175        pub unsafe fn controllerInterface(&self) -> Retained<IOUSBHostControllerInterface>;
176    );
177}
178
179/// Methods declared on superclass `NSObject`.
180impl IOUSBHostCIEndpointStateMachine {
181    extern_methods!(
182        #[unsafe(method(new))]
183        #[unsafe(method_family = new)]
184        pub unsafe fn new() -> Retained<Self>;
185    );
186}