objc2_io_usb_host/generated/IOUSBHostInterface.rs
1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4#[cfg(feature = "dispatch2")]
5use dispatch2::*;
6use objc2::__framework_prelude::*;
7#[cfg(feature = "objc2-core-foundation")]
8use objc2_core_foundation::*;
9use objc2_foundation::*;
10#[cfg(feature = "objc2-io-kit")]
11use objc2_io_kit::*;
12
13use crate::*;
14
15extern_class!(
16 /// The IOUSBHostObject representing a USB interface
17 ///
18 /// This class provides functionality to send control requests to the default control endpoint, as well as
19 /// create IOUSBHostPipe objects to transfer data.
20 ///
21 /// See also [Apple's documentation](https://developer.apple.com/documentation/iousbhost/iousbhostinterface?language=objc)
22 #[unsafe(super(IOUSBHostObject, NSObject))]
23 #[derive(Debug, PartialEq, Eq, Hash)]
24 #[cfg(feature = "IOUSBHostObject")]
25 pub struct IOUSBHostInterface;
26);
27
28#[cfg(feature = "IOUSBHostObject")]
29extern_conformance!(
30 unsafe impl NSObjectProtocol for IOUSBHostInterface {}
31);
32
33#[cfg(feature = "IOUSBHostObject")]
34impl IOUSBHostInterface {
35 extern_methods!(
36 #[cfg(feature = "objc2-core-foundation")]
37 /// Creates a matching dictionary for an IOUSBHostInterface to be passed into
38 /// IOServiceGetMatchingService
39 ///
40 /// Parameter `vendorID`: NSNumber representation of device vendorID
41 ///
42 /// Parameter `productID`: NSNumber representation of device productID
43 ///
44 /// Parameter `bcdDevice`: NSNumber representation of device release number
45 ///
46 /// Parameter `interfaceNumber`: NSNumber representation of interface number
47 ///
48 /// Parameter `configurationValue`: NSNumber representation of the device's configurationValue
49 ///
50 /// Parameter `interfaceClass`: NSNumber representation of interface class
51 ///
52 /// Parameter `interfaceSubclass`: NSNumber representation of interface subclass
53 ///
54 /// Parameter `interfaceProtocol`: NSNumber representation of interface protocol
55 ///
56 /// Parameter `speed`: NSNumber representation of device speed
57 ///
58 /// Parameter `productIDArray`: NSArray of NSNumbers representing all productIDs interested in.
59 /// If used do not specify the NSNumber productID field
60 ///
61 /// Returns: CFMutableDictionaryRef to be used with IOService matching methods. To be released
62 /// by caller.
63 ///
64 /// # Safety
65 ///
66 /// - `product_id_array` generic should be of the correct type.
67 /// - The returned generics must be of the correct type.
68 #[unsafe(method(createMatchingDictionaryWithVendorID:productID:bcdDevice:interfaceNumber:configurationValue:interfaceClass:interfaceSubclass:interfaceProtocol:speed:productIDArray:))]
69 #[unsafe(method_family = none)]
70 pub unsafe fn createMatchingDictionaryWithVendorID_productID_bcdDevice_interfaceNumber_configurationValue_interfaceClass_interfaceSubclass_interfaceProtocol_speed_productIDArray(
71 vendor_id: Option<&NSNumber>,
72 product_id: Option<&NSNumber>,
73 bcd_device: Option<&NSNumber>,
74 interface_number: Option<&NSNumber>,
75 configuration_value: Option<&NSNumber>,
76 interface_class: Option<&NSNumber>,
77 interface_subclass: Option<&NSNumber>,
78 interface_protocol: Option<&NSNumber>,
79 speed: Option<&NSNumber>,
80 product_id_array: Option<&NSArray>,
81 ) -> Retained<CFMutableDictionary>;
82
83 #[cfg(all(
84 feature = "IOUSBHostDefinitions",
85 feature = "block2",
86 feature = "dispatch2",
87 feature = "objc2-io-kit"
88 ))]
89 /// Initializes IOUSBHostInterface object along with user client
90 ///
91 /// See IOUSBHostObject for documentation.
92 ///
93 /// # Safety
94 ///
95 /// - `queue` possibly has additional threading requirements.
96 /// - `interest_handler` must be a valid pointer or null.
97 #[unsafe(method(initWithIOService:options:queue:error:interestHandler:))]
98 #[unsafe(method_family = init)]
99 pub unsafe fn initWithIOService_options_queue_error_interestHandler(
100 this: Allocated<Self>,
101 io_service: io_service_t,
102 options: IOUSBHostObjectInitOptions,
103 queue: Option<&DispatchQueue>,
104 error: Option<&mut Option<Retained<NSError>>>,
105 interest_handler: IOUSBHostInterestHandler,
106 ) -> Option<Retained<Self>>;
107
108 /// Retrieve the current idle suspend timeout.
109 /// See
110 ///
111 /// ```text
112 /// setIdleTimeout
113 /// ```
114 ///
115 ///
116 /// Returns: The amount of time after all pipes are idle to wait before
117 /// suspending the device,
118 #[unsafe(method(idleTimeout))]
119 #[unsafe(method_family = none)]
120 pub unsafe fn idleTimeout(&self) -> NSTimeInterval;
121
122 /// Sets the desired idle suspend timeout for the interface
123 ///
124 /// Once the interface is considered idle, it will defer electrical suspend of the
125 /// device for the specified duration.
126 ///
127 /// Parameter `idleTimeout`: The amount of time after all pipes are idle to
128 /// wait before suspending the device.
129 ///
130 /// Returns: YES on success. An IOReturn error code will be reported on failure.
131 #[unsafe(method(setIdleTimeout:error:_))]
132 #[unsafe(method_family = none)]
133 pub unsafe fn setIdleTimeout_error(
134 &self,
135 idle_timeout: NSTimeInterval,
136 ) -> Result<(), Retained<NSError>>;
137
138 #[cfg(feature = "objc2-io-kit")]
139 /// Retrieve the configuration descriptor associated with this interface
140 ///
141 /// Returns: IOUSBConfigurationDescriptor pointer
142 #[unsafe(method(configurationDescriptor))]
143 #[unsafe(method_family = none)]
144 pub unsafe fn configurationDescriptor(&self) -> NonNull<IOUSBConfigurationDescriptor>;
145
146 #[cfg(feature = "objc2-io-kit")]
147 /// Retrieve the interface descriptor associated with this interface.
148 ///
149 /// Returns: IOUSBInterfaceDescriptor pointer
150 #[unsafe(method(interfaceDescriptor))]
151 #[unsafe(method_family = none)]
152 pub unsafe fn interfaceDescriptor(&self) -> NonNull<IOUSBInterfaceDescriptor>;
153
154 /// Select an alternate setting for this interface
155 ///
156 /// This method is used to select an alternate setting for the interface. All pending IO
157 /// on the interface's pipes will be aborted, and the open pipes will be closed. The
158 /// IOUSBHostPipe objects already created will no longer be valid. The new alternate
159 /// setting will be selected via SET_INTERFACE control request (USB 2.0 9.4.10).
160 ///
161 /// Parameter `alternateSetting`: Alternate interface number to activate
162 ///
163 /// Returns: YES on success, an IOReturn error code will be reported on failure.
164 #[unsafe(method(selectAlternateSetting:error:_))]
165 #[unsafe(method_family = none)]
166 pub unsafe fn selectAlternateSetting_error(
167 &self,
168 alternate_setting: NSUInteger,
169 ) -> Result<(), Retained<NSError>>;
170
171 #[cfg(all(feature = "IOUSBHostIOSource", feature = "IOUSBHostPipe"))]
172 /// Return the pipe whose
173 /// <code>
174 /// bEndpointAddress
175 /// </code>
176 /// matches
177 /// <code>
178 /// address
179 /// </code>
180 ///
181 /// This method will return the pipe whose
182 /// <code>
183 /// bEndpointAddress
184 /// </code>
185 /// matches
186 /// <code>
187 /// address
188 /// </code>
189 /// . If the pipe is returned successfully, it will maintain
190 /// a reference to the IOUSBHostInterface.
191 ///
192 /// Parameter `address`: Endpoint address of the pipe
193 ///
194 /// Returns: Pointer to an IOUSBHostPipe object or nil. The IOUSBHostPipe is to be released by the caller.
195 /// An IOReturn error code will be reported on failure.
196 #[unsafe(method(copyPipeWithAddress:error:_))]
197 #[unsafe(method_family = copy)]
198 pub unsafe fn copyPipeWithAddress_error(
199 &self,
200 address: NSUInteger,
201 ) -> Result<Retained<IOUSBHostPipe>, Retained<NSError>>;
202 );
203}
204
205/// Methods declared on superclass `IOUSBHostObject`.
206#[cfg(feature = "IOUSBHostObject")]
207impl IOUSBHostInterface {
208 extern_methods!(
209 #[unsafe(method(init))]
210 #[unsafe(method_family = init)]
211 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
212
213 #[cfg(all(feature = "block2", feature = "dispatch2", feature = "objc2-io-kit"))]
214 /// Initializes IOUSBHostObject object along with user client
215 ///
216 /// This method should be called from either IOUSBHostDevice or IOUSBHostInterface.
217 /// If the io_service_t is not found nil will be returned. If an IOUSBHostDevice or
218 /// IOUSBHostInterface user client is already created, nil will be returned.
219 /// Upon creation, exclusive ownership of the IOService will be established. When done
220 /// using the object destroy must be called on the object.
221 ///
222 /// Parameter `ioService`: io_service_t of the IOUSBHostDevice or IOUSBHostInterface
223 /// the user client is for. The IOUSBHostObject will keep a reference to the io_service_t
224 /// and release it after the IOUSBHostObject has been released.
225 ///
226 /// Parameter `queue`: A serial queue that all asynchronous io will be serviced. By
227 /// default a serial queue will be created on behalf of the client. Setting
228 /// a queue will create a dispatch source event handler for the target queue to service
229 /// all underlying io.
230 ///
231 /// Parameter `interestHandler`: IOUSBHostInterestHandler a generalInterest IOService handler. This is
232 /// to handle underlying service state changes such as termination. See
233 /// IOServiceAddInterestNotification in IOKitLib for more details. All notifications will be serviced
234 /// on an internal serial queue separate from the IO queue.
235 ///
236 /// Returns: An IOUSBHostDevice or IOUSBHostInterface. The object is to be released by the caller.
237 /// An IOReturn error code will be reported on failure.
238 ///
239 /// # Safety
240 ///
241 /// - `queue` possibly has additional threading requirements.
242 /// - `interest_handler` must be a valid pointer or null.
243 #[unsafe(method(initWithIOService:queue:error:interestHandler:))]
244 #[unsafe(method_family = init)]
245 pub unsafe fn initWithIOService_queue_error_interestHandler(
246 this: Allocated<Self>,
247 io_service: io_service_t,
248 queue: Option<&DispatchQueue>,
249 error: Option<&mut Option<Retained<NSError>>>,
250 interest_handler: IOUSBHostInterestHandler,
251 ) -> Option<Retained<Self>>;
252 );
253}
254
255/// Methods declared on superclass `NSObject`.
256#[cfg(feature = "IOUSBHostObject")]
257impl IOUSBHostInterface {
258 extern_methods!(
259 #[unsafe(method(new))]
260 #[unsafe(method_family = new)]
261 pub unsafe fn new() -> Retained<Self>;
262 );
263}