objc2_io_usb_host/generated/IOUSBHostStream.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 /// [Apple's documentation](https://developer.apple.com/documentation/iousbhost/iousbhoststream?language=objc)
11 #[unsafe(super(IOUSBHostIOSource, NSObject))]
12 #[derive(Debug, PartialEq, Eq, Hash)]
13 #[cfg(feature = "IOUSBHostIOSource")]
14 pub struct IOUSBHostStream;
15);
16
17#[cfg(feature = "IOUSBHostIOSource")]
18extern_conformance!(
19 unsafe impl NSObjectProtocol for IOUSBHostStream {}
20);
21
22#[cfg(feature = "IOUSBHostIOSource")]
23impl IOUSBHostStream {
24 extern_methods!(
25 #[cfg(feature = "IOUSBHostPipe")]
26 /// Returns the IOUSBHostPipe this stream was created from
27 ///
28 /// Returns: IOUSBHostPipe pointer
29 #[unsafe(method(hostPipe))]
30 #[unsafe(method_family = none)]
31 pub unsafe fn hostPipe(&self) -> Retained<IOUSBHostPipe>;
32
33 /// Returns streamID associated with this IOUSBHostStream.
34 ///
35 /// Returns: streamID
36 #[unsafe(method(streamID))]
37 #[unsafe(method_family = none)]
38 pub unsafe fn streamID(&self) -> NSUInteger;
39
40 #[cfg(feature = "IOUSBHostDefinitions")]
41 /// Abort pending I/O requests.
42 ///
43 /// A stream context must be set as non-active on the device via an out-of-band
44 /// (class-defined) mechanism before this method is called (USB 3.1 8.12.1.4).
45 /// A non-active stream will not be selected by the device to become the current
46 /// stream on the endpoint.
47 ///
48 /// Parameter `option`: IOUSBHostAbortOption by default IOUSBHostAbortOptionSynchronous is used
49 ///
50 /// Returns: YES on success, an IOReturn error code will be reported on failure
51 #[unsafe(method(abortWithOption:error:_))]
52 #[unsafe(method_family = none)]
53 pub unsafe fn abortWithOption_error(
54 &self,
55 option: IOUSBHostAbortOption,
56 ) -> Result<(), Retained<NSError>>;
57
58 /// Abort pending I/O requests.
59 ///
60 /// A stream context must be set as non-active on the device via an out-of-band
61 /// (class-defined) mechanism before this method is called (USB 3.1 8.12.1.4).
62 /// A non-active stream will not be selected by the device to become the current
63 /// stream on the endpoint.
64 ///
65 /// Returns: YES on success, an IOReturn error code will be reported on failure
66 #[unsafe(method(abortWithError:_))]
67 #[unsafe(method_family = none)]
68 pub unsafe fn abortWithError(&self) -> Result<(), Retained<NSError>>;
69
70 /// Send an IO request on the source
71 ///
72 /// This method will send a synchronous request on the IO source, and will not return
73 /// until the request is complete. CompletionTimeouts are not applicable to streams.
74 ///
75 /// Parameter `data`: NSData* pointer containing the buffer to use for the transfer
76 ///
77 /// Parameter `bytesTransferred`: NSUInteger reference which will be updated with the bytes
78 /// transferred during the request
79 ///
80 /// Returns: YES on success, an IOReturn error code will be reported on failure
81 ///
82 /// # Safety
83 ///
84 /// `bytes_transferred` must be a valid pointer or null.
85 #[unsafe(method(sendIORequestWithData:bytesTransferred:error:_))]
86 #[unsafe(method_family = none)]
87 pub unsafe fn sendIORequestWithData_bytesTransferred_error(
88 &self,
89 data: Option<&NSMutableData>,
90 bytes_transferred: *mut NSUInteger,
91 ) -> Result<(), Retained<NSError>>;
92
93 #[cfg(all(feature = "IOUSBHostDefinitions", feature = "block2"))]
94 /// Enqueue an IO request on the source
95 ///
96 /// This method is used to issue an asynchronous I/O request on the IO source.
97 /// CompletionTimeouts are not applicable to streams.
98 ///
99 /// Parameter `data`: pointer containing the buffer to use for the transfer
100 ///
101 /// Returns: YES on success, an IOReturn error code will be reported on failure
102 ///
103 /// # Safety
104 ///
105 /// `completion_handler` must be a valid pointer or null.
106 #[unsafe(method(enqueueIORequestWithData:error:completionHandler:))]
107 #[unsafe(method_family = none)]
108 pub unsafe fn enqueueIORequestWithData_error_completionHandler(
109 &self,
110 data: Option<&NSMutableData>,
111 error: Option<&mut Option<Retained<NSError>>>,
112 completion_handler: IOUSBHostCompletionHandler,
113 ) -> bool;
114 );
115}
116
117/// Methods declared on superclass `IOUSBHostIOSource`.
118#[cfg(feature = "IOUSBHostIOSource")]
119impl IOUSBHostStream {
120 extern_methods!(
121 #[unsafe(method(init))]
122 #[unsafe(method_family = init)]
123 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
124 );
125}
126
127/// Methods declared on superclass `NSObject`.
128#[cfg(feature = "IOUSBHostIOSource")]
129impl IOUSBHostStream {
130 extern_methods!(
131 #[unsafe(method(new))]
132 #[unsafe(method_family = new)]
133 pub unsafe fn new() -> Retained<Self>;
134 );
135}