objc2_io_usb_host/generated/IOUSBHostObject.rs
1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5#[cfg(feature = "dispatch2")]
6use dispatch2::*;
7use objc2::__framework_prelude::*;
8use objc2_foundation::*;
9#[cfg(feature = "objc2-io-kit")]
10use objc2_io_kit::*;
11
12use crate::*;
13
14/// [Apple's documentation](https://developer.apple.com/documentation/iousbhost/iousbhostinteresthandler?language=objc)
15#[cfg(feature = "block2")]
16pub type IOUSBHostInterestHandler =
17 *mut block2::DynBlock<dyn Fn(NonNull<IOUSBHostObject>, u32, *mut c_void)>;
18
19extern_class!(
20 /// The Abstract class IOUSBHostDevice and IOUSBHostInterface derive from.
21 ///
22 /// Defines common methods that are shared between IOUSBHostDevice and IOUSBHostInterface including instance
23 /// management.
24 ///
25 /// See also [Apple's documentation](https://developer.apple.com/documentation/iousbhost/iousbhostobject?language=objc)
26 #[unsafe(super(NSObject))]
27 #[derive(Debug, PartialEq, Eq, Hash)]
28 pub struct IOUSBHostObject;
29);
30
31extern_conformance!(
32 unsafe impl NSObjectProtocol for IOUSBHostObject {}
33);
34
35impl IOUSBHostObject {
36 extern_methods!(
37 #[unsafe(method(init))]
38 #[unsafe(method_family = init)]
39 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
40
41 #[cfg(all(
42 feature = "IOUSBHostDefinitions",
43 feature = "block2",
44 feature = "dispatch2",
45 feature = "objc2-io-kit"
46 ))]
47 /// Initializes IOUSBHostObject object along with user client
48 ///
49 /// If the io_service_t is not found nil will be returned. If an IOUSBHostDevice or
50 /// IOUSBHostInterface user client is already created, nil will be returned.
51 /// Upon creation, exclusive ownership of the IOService will be established. When done
52 /// using the object destroy must be called on the object.
53 ///
54 /// Parameter `ioService`: io_service_t of the IOUSBHostDevice or IOUSBHostInterface
55 /// the user client is for. The IOUSBHostObject will keep a reference to the io_service_t
56 /// and release it after the IOUSBHostObject has been released.
57 ///
58 /// Parameter `options`: IOUSBHostObjectInitOptions. Default value is IOUSBHostObjectInitOptionsNone
59 ///
60 /// Parameter `queue`: A serial queue that all asynchronous io will be serviced. By
61 /// default a serial queue will be created on behalf of the client. Setting
62 /// a queue will create a dispatch source event handler for the target queue to service
63 /// all underlying io.
64 ///
65 /// Parameter `interestHandler`: IOUSBHostInterestHandler a generalInterest IOService handler. This is
66 /// to handle underlying service state changes such as termination. See
67 /// IOServiceAddInterestNotification in IOKitLib for more details. All notifications will be serviced
68 /// on an internal serial queue separate from the IO queue.
69 ///
70 /// Returns: An IOUSBHostDevice or IOUSBHostInterface. The object is to be released by the caller.
71 /// An IOReturn error code will be reported on failure.
72 ///
73 /// # Safety
74 ///
75 /// - `queue` possibly has additional threading requirements.
76 /// - `interest_handler` must be a valid pointer or null.
77 #[unsafe(method(initWithIOService:options:queue:error:interestHandler:))]
78 #[unsafe(method_family = init)]
79 pub unsafe fn initWithIOService_options_queue_error_interestHandler(
80 this: Allocated<Self>,
81 io_service: io_service_t,
82 options: IOUSBHostObjectInitOptions,
83 queue: Option<&DispatchQueue>,
84 error: Option<&mut Option<Retained<NSError>>>,
85 interest_handler: IOUSBHostInterestHandler,
86 ) -> Option<Retained<Self>>;
87
88 #[cfg(all(feature = "block2", feature = "dispatch2", feature = "objc2-io-kit"))]
89 /// Initializes IOUSBHostObject object along with user client
90 ///
91 /// This method should be called from either IOUSBHostDevice or IOUSBHostInterface.
92 /// If the io_service_t is not found nil will be returned. If an IOUSBHostDevice or
93 /// IOUSBHostInterface user client is already created, nil will be returned.
94 /// Upon creation, exclusive ownership of the IOService will be established. When done
95 /// using the object destroy must be called on the object.
96 ///
97 /// Parameter `ioService`: io_service_t of the IOUSBHostDevice or IOUSBHostInterface
98 /// the user client is for. The IOUSBHostObject will keep a reference to the io_service_t
99 /// and release it after the IOUSBHostObject has been released.
100 ///
101 /// Parameter `queue`: A serial queue that all asynchronous io will be serviced. By
102 /// default a serial queue will be created on behalf of the client. Setting
103 /// a queue will create a dispatch source event handler for the target queue to service
104 /// all underlying io.
105 ///
106 /// Parameter `interestHandler`: IOUSBHostInterestHandler a generalInterest IOService handler. This is
107 /// to handle underlying service state changes such as termination. See
108 /// IOServiceAddInterestNotification in IOKitLib for more details. All notifications will be serviced
109 /// on an internal serial queue separate from the IO queue.
110 ///
111 /// Returns: An IOUSBHostDevice or IOUSBHostInterface. The object is to be released by the caller.
112 /// An IOReturn error code will be reported on failure.
113 ///
114 /// # Safety
115 ///
116 /// - `queue` possibly has additional threading requirements.
117 /// - `interest_handler` must be a valid pointer or null.
118 #[unsafe(method(initWithIOService:queue:error:interestHandler:))]
119 #[unsafe(method_family = init)]
120 pub unsafe fn initWithIOService_queue_error_interestHandler(
121 this: Allocated<Self>,
122 io_service: io_service_t,
123 queue: Option<&DispatchQueue>,
124 error: Option<&mut Option<Retained<NSError>>>,
125 interest_handler: IOUSBHostInterestHandler,
126 ) -> Option<Retained<Self>>;
127
128 /// Removes underlying allocations of the IOUSBHostObject object along with user client
129 ///
130 /// When the IOUSBHostObject is no longer needed, destroy must be called. This will destroy
131 /// the connection with the user client and de-register interest on the service. If the object
132 /// is free'd destroy will be called automatically. Calling destroy multiple times has no effect.
133 #[unsafe(method(destroy))]
134 #[unsafe(method_family = none)]
135 pub unsafe fn destroy(&self);
136
137 #[cfg(feature = "IOUSBHostDefinitions")]
138 /// Removes underlying allocations of the IOUSBHostObject object along with user client
139 ///
140 /// Extends
141 /// <code>
142 /// destroy
143 /// </code>
144 /// to take an options to modify the destroy behavior. Currently only the
145 /// <code>
146 /// IOUSBHostObjectDestroyOptionsDeviceSurrender
147 /// </code>
148 /// is defined to support surrendering ownersip of
149 /// the kernel service. To be used when accepting the
150 /// <code>
151 /// kUSBHostMessageDeviceIsRequestingClose
152 /// </code>
153 /// message.
154 #[unsafe(method(destroyWithOptions:))]
155 #[unsafe(method_family = none)]
156 pub unsafe fn destroyWithOptions(&self, options: IOUSBHostObjectDestroyOptions);
157
158 #[cfg(feature = "objc2-io-kit")]
159 /// Retrieve the IOUSBHostObject's io_service_t.
160 #[unsafe(method(ioService))]
161 #[unsafe(method_family = none)]
162 pub unsafe fn ioService(&self) -> io_service_t;
163
164 #[cfg(feature = "dispatch2")]
165 /// The dispatch queue that all asynchronous io will be serviced.
166 #[unsafe(method(queue))]
167 #[unsafe(method_family = none)]
168 pub unsafe fn queue(&self) -> Retained<DispatchQueue>;
169
170 #[cfg(feature = "objc2-io-kit")]
171 /// Send a request on the default control endpoint
172 ///
173 /// This method will send a synchronous request on the default control endpoint, and
174 /// will not return until the request is complete.
175 ///
176 /// Parameter `request`: IOUSBDeviceRequest structure.
177 ///
178 /// Parameter `data`: An NSMutableData* defining the memory to use for the request's data phase.
179 ///
180 /// Parameter `bytesTransferred`: Optional NSUInteger reference which will be updated with the byte
181 /// count of the completed data phase.
182 ///
183 /// Parameter `completionTimeout`: Timeout of the request. If 0, the request will never timeout. By
184 /// default this value is IOUSBHostDefaultControlCompletionTimeout.
185 ///
186 /// Returns: YES on success, an IOReturn error code will be reported on failure.
187 ///
188 /// # Safety
189 ///
190 /// `bytes_transferred` must be a valid pointer or null.
191 #[unsafe(method(sendDeviceRequest:data:bytesTransferred:completionTimeout:error:_))]
192 #[unsafe(method_family = none)]
193 pub unsafe fn sendDeviceRequest_data_bytesTransferred_completionTimeout_error(
194 &self,
195 request: IOUSBDeviceRequest,
196 data: Option<&NSMutableData>,
197 bytes_transferred: *mut NSUInteger,
198 completion_timeout: NSTimeInterval,
199 ) -> Result<(), Retained<NSError>>;
200
201 #[cfg(feature = "objc2-io-kit")]
202 /// Send a request on the default control endpoint
203 ///
204 /// This method will send a synchronous request on the default control endpoint, and
205 /// will not return until the request is complete.
206 ///
207 /// Parameter `request`: IOUSBDeviceRequest structure.
208 ///
209 /// Parameter `data`: An NSMutableData* defining the memory to use for the request's data phase.
210 ///
211 /// Parameter `bytesTransferred`: Optional NSUInteger reference which will be updated with the byte
212 /// count of the completed data phase.
213 ///
214 /// Returns: YES on success, an IOReturn error code will be reported on failure.
215 ///
216 /// # Safety
217 ///
218 /// `bytes_transferred` must be a valid pointer or null.
219 #[unsafe(method(sendDeviceRequest:data:bytesTransferred:error:_))]
220 #[unsafe(method_family = none)]
221 pub unsafe fn sendDeviceRequest_data_bytesTransferred_error(
222 &self,
223 request: IOUSBDeviceRequest,
224 data: Option<&NSMutableData>,
225 bytes_transferred: *mut NSUInteger,
226 ) -> Result<(), Retained<NSError>>;
227
228 #[cfg(feature = "objc2-io-kit")]
229 /// Send a request on the default control endpoint
230 ///
231 /// This method will send a synchronous request on the default control endpoint, and
232 /// will not return until the request is complete.
233 ///
234 /// Parameter `request`: IOUSBDeviceRequest structure.
235 ///
236 /// Returns: YES on success, an IOReturn error code will be reported on failure.
237 #[unsafe(method(sendDeviceRequest:error:_))]
238 #[unsafe(method_family = none)]
239 pub unsafe fn sendDeviceRequest_error(
240 &self,
241 request: IOUSBDeviceRequest,
242 ) -> Result<(), Retained<NSError>>;
243
244 #[cfg(all(
245 feature = "IOUSBHostDefinitions",
246 feature = "block2",
247 feature = "objc2-io-kit"
248 ))]
249 /// Enqueue a request on the default control endpoint
250 ///
251 /// This method will enqueue an asynchronous request on the default control endpoint.
252 /// If successful, the provided completionHandler will be called to report the status
253 /// of the completed IO.
254 ///
255 /// Parameter `data`: An NSMutableData* defining the memory to use for the request's data phase.
256 ///
257 /// Parameter `completionTimeout`: Timeout of the request. If 0, the request will never timeout. By
258 /// default this value is IOUSBHostDefaultControlCompletionTimeout
259 ///
260 /// Parameter `completionHandler`: an IOUSBHostCompletionHandler
261 ///
262 /// Returns: YES on success, an IOReturn error code will be reported on failure
263 ///
264 /// # Safety
265 ///
266 /// `completion_handler` must be a valid pointer or null.
267 #[unsafe(method(enqueueDeviceRequest:data:completionTimeout:error:completionHandler:))]
268 #[unsafe(method_family = none)]
269 pub unsafe fn enqueueDeviceRequest_data_completionTimeout_error_completionHandler(
270 &self,
271 request: IOUSBDeviceRequest,
272 data: Option<&NSMutableData>,
273 completion_timeout: NSTimeInterval,
274 error: Option<&mut Option<Retained<NSError>>>,
275 completion_handler: IOUSBHostCompletionHandler,
276 ) -> bool;
277
278 #[cfg(all(
279 feature = "IOUSBHostDefinitions",
280 feature = "block2",
281 feature = "objc2-io-kit"
282 ))]
283 /// Enqueue a request on the default control endpoint
284 ///
285 /// This method will enqueue an asynchronous request on the default control endpoint.
286 /// If successful, the provided completionHandler will be called to report the status
287 /// of the completed IO.
288 ///
289 /// Parameter `data`: An NSMutableData* defining the memory to use for the request's data phase.
290 ///
291 /// Parameter `completionHandler`: an IOUSBHostCompletionHandler
292 ///
293 /// Returns: YES on success, an IOReturn error code will be reported on failure
294 ///
295 /// # Safety
296 ///
297 /// `completion_handler` must be a valid pointer or null.
298 #[unsafe(method(enqueueDeviceRequest:data:error:completionHandler:))]
299 #[unsafe(method_family = none)]
300 pub unsafe fn enqueueDeviceRequest_data_error_completionHandler(
301 &self,
302 request: IOUSBDeviceRequest,
303 data: Option<&NSMutableData>,
304 error: Option<&mut Option<Retained<NSError>>>,
305 completion_handler: IOUSBHostCompletionHandler,
306 ) -> bool;
307
308 #[cfg(all(
309 feature = "IOUSBHostDefinitions",
310 feature = "block2",
311 feature = "objc2-io-kit"
312 ))]
313 /// Enqueue a request on the default control endpoint
314 ///
315 /// This method will enqueue an asynchronous request on the default control endpoint.
316 /// If successful, the provided completionHandler will be called to report the status
317 /// of the completed IO.
318 /// default this value is IOUSBHostDefaultControlCompletionTimeout
319 ///
320 /// Parameter `completionHandler`: an IOUSBHostCompletionHandler
321 ///
322 /// Returns: YES on success, an IOReturn error code will be reported on failure
323 ///
324 /// # Safety
325 ///
326 /// `completion_handler` must be a valid pointer or null.
327 #[unsafe(method(enqueueDeviceRequest:error:completionHandler:))]
328 #[unsafe(method_family = none)]
329 pub unsafe fn enqueueDeviceRequest_error_completionHandler(
330 &self,
331 request: IOUSBDeviceRequest,
332 error: Option<&mut Option<Retained<NSError>>>,
333 completion_handler: IOUSBHostCompletionHandler,
334 ) -> bool;
335
336 #[cfg(feature = "IOUSBHostDefinitions")]
337 /// Abort device requests
338 ///
339 /// This method will abort any requests made via the
340 ///
341 /// ```text
342 /// sendDeviceRequest
343 /// ```
344 ///
345 /// and
346 ///
347 /// ```text
348 /// enqueueDeviceRequest
349 /// ```
350 ///
351 /// methods.
352 ///
353 /// Parameter `option`: IOUSBHostAbortOption by default IOUSBHostAbortOptionSynchronous is used
354 ///
355 /// Returns: YES on success, an IOReturn error code will be reported on failure
356 #[unsafe(method(abortDeviceRequestsWithOption:error:_))]
357 #[unsafe(method_family = none)]
358 pub unsafe fn abortDeviceRequestsWithOption_error(
359 &self,
360 option: IOUSBHostAbortOption,
361 ) -> Result<(), Retained<NSError>>;
362
363 /// Abort device requests
364 ///
365 /// This method will abort any requests made via the
366 ///
367 /// ```text
368 /// sendDeviceRequest
369 /// ```
370 ///
371 /// and
372 ///
373 /// ```text
374 /// enqueueDeviceRequest
375 /// ```
376 ///
377 /// methods.
378 ///
379 /// Returns: YES on success, an IOReturn error code will be reported on failure
380 #[unsafe(method(abortDeviceRequestsWithError:_))]
381 #[unsafe(method_family = none)]
382 pub unsafe fn abortDeviceRequestsWithError(&self) -> Result<(), Retained<NSError>>;
383
384 #[cfg(feature = "objc2-io-kit")]
385 /// Retrieve a descriptor from the cache or the device
386 ///
387 /// This method will search the descriptor cache for the descriptor that matches the
388 /// input arguments. If the descriptor is not in the cache, a GET_DESCRIPTOR control
389 /// request (USB 2.0 9.4.3) will be issued to retrieve the descriptor from the device.
390 /// If the device request is successful, the retrieved descriptor will be added to the
391 /// cache.
392 ///
393 /// Parameter `type`: <code>
394 /// bDescriptorType
395 /// </code>
396 /// of the descriptor to find.
397 ///
398 /// Parameter `length`: Reference to a NSUInteger which will be updated with the length of the
399 /// descriptor. As input, used as
400 /// <code>
401 /// wLength
402 /// </code>
403 /// when fetching variable-length
404 /// configuration or BOS descriptors, or when fetching nonstandard descriptor types.
405 ///
406 /// Parameter `index`: Descriptor index value. Low byte of
407 /// <code>
408 /// wValue
409 /// </code>
410 /// of the SET_DESCRIPTOR
411 /// control request (USB 2.0 9.4.8). By default the value is 0
412 ///
413 /// Parameter `languageID`: Descriptor language ID.
414 /// <code>
415 /// wIndex
416 /// </code>
417 /// of the SET_DESCRIPTOR
418 /// control request (USB 2.0 9.4.8). By default the value is 0
419 ///
420 /// Parameter `requestType`: tDeviceRequestType to be used for a GET_DESCRIPTOR control request.
421 /// By default the value is IOUSBRequestTypeStandard
422 ///
423 /// Parameter `requestRecipient`: tDeviceRequestRecipient to be used for a GET_DESCRIPTOR control
424 /// request. By default the value is IOUSBRequestRecipientDevice
425 ///
426 /// Returns: Pointer to the cached descriptor if found, otherwise nil. An IOReturn error code
427 /// will be reported on failure.
428 ///
429 /// # Safety
430 ///
431 /// `length` must be a valid pointer.
432 #[unsafe(method(descriptorWithType:length:index:languageID:requestType:requestRecipient:error:))]
433 #[unsafe(method_family = none)]
434 pub unsafe fn descriptorWithType_length_index_languageID_requestType_requestRecipient_error(
435 &self,
436 r#type: tIOUSBDescriptorType,
437 length: NonNull<NSUInteger>,
438 index: NSUInteger,
439 language_id: NSUInteger,
440 request_type: tIOUSBDeviceRequestTypeValue,
441 request_recipient: tIOUSBDeviceRequestRecipientValue,
442 error: Option<&mut Option<Retained<NSError>>>,
443 ) -> *const IOUSBDescriptor;
444
445 #[cfg(feature = "objc2-io-kit")]
446 /// Retrieve a descriptor from the cache or the device
447 ///
448 /// This method will search the descriptor cache for the descriptor that matches the
449 /// input arguments. If the descriptor is not in the cache, a GET_DESCRIPTOR control
450 /// request (USB 2.0 9.4.3) will be issued to retrieve the descriptor from the device.
451 /// If the device request is successful, the retrieved descriptor will be added to the
452 /// cache.
453 ///
454 /// Parameter `type`: <code>
455 /// bDescriptorType
456 /// </code>
457 /// of the descriptor to find.
458 ///
459 /// Parameter `length`: Reference to a NSUInteger which will be updated with the length of the
460 /// descriptor. As input, used as
461 /// <code>
462 /// wLength
463 /// </code>
464 /// when fetching variable-length
465 /// configuration or BOS descriptors, or when fetching nonstandard descriptor types.
466 ///
467 /// Parameter `index`: Descriptor index value. Low byte of
468 /// <code>
469 /// wValue
470 /// </code>
471 /// of the SET_DESCRIPTOR
472 /// control request (USB 2.0 9.4.8). By default the value is 0
473 ///
474 /// Parameter `languageID`: Descriptor language ID.
475 /// <code>
476 /// wIndex
477 /// </code>
478 /// of the SET_DESCRIPTOR
479 /// control request (USB 2.0 9.4.8). By default the value is 0
480 ///
481 /// Returns: Pointer to the cached descriptor if found, otherwise nil. An IOReturn error code
482 /// will be reported on failure.
483 ///
484 /// # Safety
485 ///
486 /// `length` must be a valid pointer.
487 #[unsafe(method(descriptorWithType:length:index:languageID:error:))]
488 #[unsafe(method_family = none)]
489 pub unsafe fn descriptorWithType_length_index_languageID_error(
490 &self,
491 r#type: tIOUSBDescriptorType,
492 length: NonNull<NSUInteger>,
493 index: NSUInteger,
494 language_id: NSUInteger,
495 error: Option<&mut Option<Retained<NSError>>>,
496 ) -> *const IOUSBDescriptor;
497
498 #[cfg(feature = "objc2-io-kit")]
499 /// Retrieve a descriptor from the cache or the device
500 ///
501 /// This method will search the descriptor cache for the descriptor that matches the
502 /// input arguments. If the descriptor is not in the cache, a GET_DESCRIPTOR control
503 /// request (USB 2.0 9.4.3) will be issued to retrieve the descriptor from the device.
504 /// If the device request is successful, the retrieved descriptor will be added to the
505 /// cache.
506 ///
507 /// Parameter `type`: <code>
508 /// bDescriptorType
509 /// </code>
510 /// of the descriptor to find.
511 ///
512 /// Parameter `length`: Reference to a NSUInteger which will be updated with the length of the
513 /// descriptor. As input, used as
514 /// <code>
515 /// wLength
516 /// </code>
517 /// when fetching variable-length
518 /// configuration or BOS descriptors, or when fetching nonstandard descriptor types.
519 /// By default the value is 0
520 ///
521 /// Returns: Pointer to the cached descriptor if found, otherwise nil. An IOReturn error code
522 /// will be reported on failure.
523 ///
524 /// # Safety
525 ///
526 /// `length` must be a valid pointer.
527 #[unsafe(method(descriptorWithType:length:error:))]
528 #[unsafe(method_family = none)]
529 pub unsafe fn descriptorWithType_length_error(
530 &self,
531 r#type: tIOUSBDescriptorType,
532 length: NonNull<NSUInteger>,
533 error: Option<&mut Option<Retained<NSError>>>,
534 ) -> *const IOUSBDescriptor;
535
536 #[cfg(feature = "objc2-io-kit")]
537 /// Return the device descriptor
538 ///
539 /// This method uses descriptorWithType to retrieve the device descriptor.
540 ///
541 /// Returns: Pointer to the device descriptor.
542 #[unsafe(method(deviceDescriptor))]
543 #[unsafe(method_family = none)]
544 pub unsafe fn deviceDescriptor(&self) -> *const IOUSBDeviceDescriptor;
545
546 #[cfg(feature = "objc2-io-kit")]
547 /// Return the capability descriptors of the device
548 ///
549 /// This method uses descriptorWithType to return the device's BOS descriptors
550 ///
551 /// Returns: Pointer to the BOS descriptor if found, otherwise nil.
552 #[unsafe(method(capabilityDescriptors))]
553 #[unsafe(method_family = none)]
554 pub unsafe fn capabilityDescriptors(&self) -> *const IOUSBBOSDescriptor;
555
556 #[cfg(feature = "objc2-io-kit")]
557 /// Return the configuration descriptor at a specified index
558 ///
559 /// This method uses descriptorWithType to retrieve the configuration descriptor.
560 ///
561 /// Parameter `index`: Descriptor index value
562 ///
563 /// Returns: Pointer of the configuration descriptor if found, otherwise nil. An IOReturn error
564 /// code will be reported on failure.
565 #[unsafe(method(configurationDescriptorWithIndex:error:))]
566 #[unsafe(method_family = none)]
567 pub unsafe fn configurationDescriptorWithIndex_error(
568 &self,
569 index: NSUInteger,
570 error: Option<&mut Option<Retained<NSError>>>,
571 ) -> *const IOUSBConfigurationDescriptor;
572
573 #[cfg(feature = "objc2-io-kit")]
574 /// Return the configuration descriptor with a specified value
575 ///
576 /// This method uses descriptorWithType to search for a configuration descriptor with a
577 /// specific
578 /// <code>
579 /// bConfigurationValue
580 /// </code>
581 /// field.
582 ///
583 /// Parameter `configurationValue`: Value to match
584 ///
585 /// Returns: Pointer of the configuration descriptor if found, otherwise nil. An IOReturn error
586 /// code will be reported on failure.
587 #[unsafe(method(configurationDescriptorWithConfigurationValue:error:))]
588 #[unsafe(method_family = none)]
589 pub unsafe fn configurationDescriptorWithConfigurationValue_error(
590 &self,
591 configuration_value: NSUInteger,
592 error: Option<&mut Option<Retained<NSError>>>,
593 ) -> *const IOUSBConfigurationDescriptor;
594
595 /// Returns the string from a string descriptor
596 ///
597 /// This method uses descriptorWithType to retrieve the string descriptor.
598 ///
599 /// Parameter `index`: Descriptor index value. Low byte of
600 /// <code>
601 /// wValue
602 /// </code>
603 /// of the
604 /// SET_DESCRIPTOR control request (USB 2.0 9.4.8).
605 ///
606 /// Parameter `languageID`: Descriptor language ID.
607 /// <code>
608 /// wIndex
609 /// </code>
610 /// of the SET_DESCRIPTOR
611 /// control request (USB 2.0 9.4.8). By default this value is kLanguageIDEnglishUS
612 ///
613 /// Returns: NSString reference to string from descriptor, an IOReturn error code will be reported on
614 /// failure.
615 #[unsafe(method(stringWithIndex:languageID:error:_))]
616 #[unsafe(method_family = none)]
617 pub unsafe fn stringWithIndex_languageID_error(
618 &self,
619 index: NSUInteger,
620 language_id: NSUInteger,
621 ) -> Result<Retained<NSString>, Retained<NSError>>;
622
623 /// Returns the string from a string descriptor
624 ///
625 /// This method uses descriptorWithType to retrieve the string descriptor.
626 ///
627 /// Parameter `index`: Descriptor index value. Low byte of
628 /// <code>
629 /// wValue
630 /// </code>
631 /// of the
632 /// SET_DESCRIPTOR control request (USB 2.0 9.4.8).
633 ///
634 /// Returns: NSString reference to string from descriptor, an IOReturn error code will be reported on
635 /// failure.
636 #[unsafe(method(stringWithIndex:error:_))]
637 #[unsafe(method_family = none)]
638 pub unsafe fn stringWithIndex_error(
639 &self,
640 index: NSUInteger,
641 ) -> Result<Retained<NSString>, Retained<NSError>>;
642
643 /// Retrieve the current address of the device.
644 #[unsafe(method(deviceAddress))]
645 #[unsafe(method_family = none)]
646 pub unsafe fn deviceAddress(&self) -> NSUInteger;
647
648 #[cfg(feature = "IOUSBHostDefinitions")]
649 /// Return the current frame number of the USB controller
650 ///
651 /// This method will return the current frame number of the USB controller,
652 /// omitting micro frame. This is most useful for scheduling future isochronous
653 /// requests.
654 ///
655 /// Parameter `time`: If not nil, this will be updated with the current system time
656 ///
657 /// Returns: The current frame number
658 ///
659 /// # Safety
660 ///
661 /// `time` must be a valid pointer or null.
662 #[unsafe(method(frameNumberWithTime:))]
663 #[unsafe(method_family = none)]
664 pub unsafe fn frameNumberWithTime(&self, time: *mut IOUSBHostTime) -> u64;
665
666 #[cfg(feature = "IOUSBHostDefinitions")]
667 /// Return the current microframe number of the USB controller
668 ///
669 /// This method will return the current microframe number of the USB controller.
670 /// This is most useful for scheduling future isochronous requests.
671 ///
672 /// Parameter `time`: If not nil, this will be updated with system time associated with the microframe.
673 ///
674 /// Returns: The current microframe number. Returns 0 on failure, with NSError populated with the IOReturn error code.
675 ///
676 /// # Safety
677 ///
678 /// `time` must be a valid pointer or null.
679 #[unsafe(method(currentMicroframeWithTime:error:))]
680 #[unsafe(method_family = none)]
681 pub unsafe fn currentMicroframeWithTime_error(
682 &self,
683 time: *mut IOUSBHostTime,
684 error: Option<&mut Option<Retained<NSError>>>,
685 ) -> u64;
686
687 #[cfg(feature = "IOUSBHostDefinitions")]
688 /// Return a recent microframe number of the USB controller
689 ///
690 /// This method will return a recent microframe number of the USB controller.
691 /// This is most useful for scheduling future isochronous requests.
692 ///
693 /// Parameter `time`: If not nil, this will be updated with system time associated with the microframe.
694 ///
695 /// Returns: A recent microframe number. Returns 0 on failure, with NSError populated with the IOReturn error code.
696 ///
697 /// # Safety
698 ///
699 /// `time` must be a valid pointer or null.
700 #[unsafe(method(referenceMicroframeWithTime:error:))]
701 #[unsafe(method_family = none)]
702 pub unsafe fn referenceMicroframeWithTime_error(
703 &self,
704 time: *mut IOUSBHostTime,
705 error: Option<&mut Option<Retained<NSError>>>,
706 ) -> u64;
707
708 /// Allocate a buffer to be used for I/O
709 ///
710 /// This method will allocate and map an IOBufferMemoryDescriptor optimized for use
711 /// by the underlying controller hardware. A buffer allocated by this method will not
712 /// be bounced to perform DMA operations.
713 /// Because the NSMutableData is backed by kernel memory, the length and capacity are
714 /// not mutable. Any changes to the length or capacity will cause an exception to be
715 /// thrown.
716 ///
717 /// Parameter `capacity`: Size of the buffer to allocate
718 ///
719 /// Returns: NSMutableData of memory mapped to user space of an IOBufferMemoryDescriptor if successful,
720 /// otherwise nil. An IOReturn error code will be reported on failure. The result is
721 /// to be released by the caller
722 #[unsafe(method(ioDataWithCapacity:error:_))]
723 #[unsafe(method_family = none)]
724 pub unsafe fn ioDataWithCapacity_error(
725 &self,
726 capacity: NSUInteger,
727 ) -> Result<Retained<NSMutableData>, Retained<NSError>>;
728 );
729}
730
731/// Methods declared on superclass `NSObject`.
732impl IOUSBHostObject {
733 extern_methods!(
734 #[unsafe(method(new))]
735 #[unsafe(method_family = new)]
736 pub unsafe fn new() -> Retained<Self>;
737 );
738}