objc2_io_usb_host/generated/IOUSBHostDevice.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 device
17 ///
18 /// This class provides functionality to send control requests to the default control endpoint
19 ///
20 /// See also [Apple's documentation](https://developer.apple.com/documentation/iousbhost/iousbhostdevice?language=objc)
21 #[unsafe(super(IOUSBHostObject, NSObject))]
22 #[derive(Debug, PartialEq, Eq, Hash)]
23 #[cfg(feature = "IOUSBHostObject")]
24 pub struct IOUSBHostDevice;
25);
26
27#[cfg(feature = "IOUSBHostObject")]
28extern_conformance!(
29 unsafe impl NSObjectProtocol for IOUSBHostDevice {}
30);
31
32#[cfg(feature = "IOUSBHostObject")]
33impl IOUSBHostDevice {
34 extern_methods!(
35 #[cfg(feature = "objc2-core-foundation")]
36 /// Creates a matching dictionary for an IOUSBHostDevice to be passed into
37 /// IOServiceGetMatchingService
38 ///
39 /// Parameter `vendorID`: NSNumber representation of device vendorID
40 ///
41 /// Parameter `productID`: NSNumber representation of device productID
42 ///
43 /// Parameter `bcdDevice`: NSNumber representation of device release number
44 ///
45 /// Parameter `deviceClass`: NSNumber representation of device class
46 ///
47 /// Parameter `deviceSubclass`: NSNumber representation of device subclass
48 ///
49 /// Parameter `deviceProtocol`: NSNumber representation of device protocol
50 ///
51 /// Parameter `speed`: NSNumber representation of device speed
52 ///
53 /// Parameter `productIDArray`: NSArray of NSNumbers representing all productIDs interested in.
54 /// If used do not specify the NSNumber productID field
55 ///
56 /// Returns: CFMutableDictionaryRef to be used with IOService matching methods. To be released by
57 /// caller.
58 ///
59 /// # Safety
60 ///
61 /// - `product_id_array` generic should be of the correct type.
62 /// - The returned generics must be of the correct type.
63 #[unsafe(method(createMatchingDictionaryWithVendorID:productID:bcdDevice:deviceClass:deviceSubclass:deviceProtocol:speed:productIDArray:))]
64 #[unsafe(method_family = none)]
65 pub unsafe fn createMatchingDictionaryWithVendorID_productID_bcdDevice_deviceClass_deviceSubclass_deviceProtocol_speed_productIDArray(
66 vendor_id: Option<&NSNumber>,
67 product_id: Option<&NSNumber>,
68 bcd_device: Option<&NSNumber>,
69 device_class: Option<&NSNumber>,
70 device_subclass: Option<&NSNumber>,
71 device_protocol: Option<&NSNumber>,
72 speed: Option<&NSNumber>,
73 product_id_array: Option<&NSArray>,
74 ) -> Retained<CFMutableDictionary>;
75
76 /// Select a new configuration for the device
77 ///
78 /// This method will select a new configuration for a device. If the device was
79 /// previously configured all child interfaces will be terminated prior to setting
80 /// the new configuration. This method will send the SET_CONFIGURATION control request
81 /// (USB 2.0 9.4.7) to the device. The interfaces will be registered for matching by
82 /// default. After the completion of this call, the interfaces are not guaranteed
83 /// to be immediately available.
84 ///
85 /// Parameter `value`: Configuration value to select
86 ///
87 /// Parameter `matchInterfaces`: If YES, any interfaces within the new configuration will be
88 /// registered for matching. By default this is set to YES.
89 ///
90 /// Returns: YES on success, an IOReturn error code will be reported on failure.
91 #[unsafe(method(configureWithValue:matchInterfaces:error:_))]
92 #[unsafe(method_family = none)]
93 pub unsafe fn configureWithValue_matchInterfaces_error(
94 &self,
95 value: NSUInteger,
96 match_interfaces: bool,
97 ) -> Result<(), Retained<NSError>>;
98
99 /// Select a new configuration for the device
100 ///
101 /// This method will select a new configuration for a device. If the device was
102 /// previously configured all child interfaces will be terminated prior to setting
103 /// the new configuration. This method will send the SET_CONFIGURATION control request
104 /// (USB 2.0 9.4.7) to the device. The interfaces will be registered for matching by
105 /// default. After the completion of this call, the interfaces are not guaranteed
106 /// to be immediately available.
107 ///
108 /// Parameter `value`: Configuration value to select
109 ///
110 /// Returns: YES on success, an IOReturn error code will be reported on failure.
111 #[unsafe(method(configureWithValue:error:_))]
112 #[unsafe(method_family = none)]
113 pub unsafe fn configureWithValue_error(
114 &self,
115 value: NSUInteger,
116 ) -> Result<(), Retained<NSError>>;
117
118 #[cfg(feature = "objc2-io-kit")]
119 /// Return the currently selected configuration descriptor
120 ///
121 /// This method uses descriptorWithType to return the configuration descriptor currently
122 /// selected after a successful setConfiguration call
123 ///
124 /// Returns: Pointer to the configuration descriptor if found, or nil if the device is not
125 /// configured
126 #[unsafe(method(configurationDescriptor))]
127 #[unsafe(method_family = none)]
128 pub unsafe fn configurationDescriptor(&self) -> *const IOUSBConfigurationDescriptor;
129
130 /// Terminate the device and attempt to reenumerate it
131 ///
132 /// This function will reset and attempt to reenumerate the USB device.
133 /// The current IOUSBHostDevice object and all of its children will be terminated.
134 /// A new IOUSBHostDevice IOService object will be created and registered if the reset
135 /// is successful and the previous object has finished terminating. The framework IOUSBHostDevice
136 /// will no longer have a valid connection with IOService userclient after the call returns
137 /// successfully. A new framework client will need to be created to use the re-enumerated device.
138 ///
139 /// Returns: YES on success, an IOReturn error code will be reported on failure.
140 #[unsafe(method(resetWithError:_))]
141 #[unsafe(method_family = none)]
142 pub unsafe fn resetWithError(&self) -> Result<(), Retained<NSError>>;
143 );
144}
145
146/// Methods declared on superclass `IOUSBHostObject`.
147#[cfg(feature = "IOUSBHostObject")]
148impl IOUSBHostDevice {
149 extern_methods!(
150 #[unsafe(method(init))]
151 #[unsafe(method_family = init)]
152 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
153
154 #[cfg(all(
155 feature = "IOUSBHostDefinitions",
156 feature = "block2",
157 feature = "dispatch2",
158 feature = "objc2-io-kit"
159 ))]
160 /// Initializes IOUSBHostObject object along with user client
161 ///
162 /// If the io_service_t is not found nil will be returned. If an IOUSBHostDevice or
163 /// IOUSBHostInterface user client is already created, nil will be returned.
164 /// Upon creation, exclusive ownership of the IOService will be established. When done
165 /// using the object destroy must be called on the object.
166 ///
167 /// Parameter `ioService`: io_service_t of the IOUSBHostDevice or IOUSBHostInterface
168 /// the user client is for. The IOUSBHostObject will keep a reference to the io_service_t
169 /// and release it after the IOUSBHostObject has been released.
170 ///
171 /// Parameter `options`: IOUSBHostObjectInitOptions. Default value is IOUSBHostObjectInitOptionsNone
172 ///
173 /// Parameter `queue`: A serial queue that all asynchronous io will be serviced. By
174 /// default a serial queue will be created on behalf of the client. Setting
175 /// a queue will create a dispatch source event handler for the target queue to service
176 /// all underlying io.
177 ///
178 /// Parameter `interestHandler`: IOUSBHostInterestHandler a generalInterest IOService handler. This is
179 /// to handle underlying service state changes such as termination. See
180 /// IOServiceAddInterestNotification in IOKitLib for more details. All notifications will be serviced
181 /// on an internal serial queue separate from the IO queue.
182 ///
183 /// Returns: An IOUSBHostDevice or IOUSBHostInterface. The object is to be released by the caller.
184 /// An IOReturn error code will be reported on failure.
185 ///
186 /// # Safety
187 ///
188 /// - `queue` possibly has additional threading requirements.
189 /// - `interest_handler` must be a valid pointer or null.
190 #[unsafe(method(initWithIOService:options:queue:error:interestHandler:))]
191 #[unsafe(method_family = init)]
192 pub unsafe fn initWithIOService_options_queue_error_interestHandler(
193 this: Allocated<Self>,
194 io_service: io_service_t,
195 options: IOUSBHostObjectInitOptions,
196 queue: Option<&DispatchQueue>,
197 error: Option<&mut Option<Retained<NSError>>>,
198 interest_handler: IOUSBHostInterestHandler,
199 ) -> Option<Retained<Self>>;
200
201 #[cfg(all(feature = "block2", feature = "dispatch2", feature = "objc2-io-kit"))]
202 /// Initializes IOUSBHostObject object along with user client
203 ///
204 /// This method should be called from either IOUSBHostDevice or IOUSBHostInterface.
205 /// If the io_service_t is not found nil will be returned. If an IOUSBHostDevice or
206 /// IOUSBHostInterface user client is already created, nil will be returned.
207 /// Upon creation, exclusive ownership of the IOService will be established. When done
208 /// using the object destroy must be called on the object.
209 ///
210 /// Parameter `ioService`: io_service_t of the IOUSBHostDevice or IOUSBHostInterface
211 /// the user client is for. The IOUSBHostObject will keep a reference to the io_service_t
212 /// and release it after the IOUSBHostObject has been released.
213 ///
214 /// Parameter `queue`: A serial queue that all asynchronous io will be serviced. By
215 /// default a serial queue will be created on behalf of the client. Setting
216 /// a queue will create a dispatch source event handler for the target queue to service
217 /// all underlying io.
218 ///
219 /// Parameter `interestHandler`: IOUSBHostInterestHandler a generalInterest IOService handler. This is
220 /// to handle underlying service state changes such as termination. See
221 /// IOServiceAddInterestNotification in IOKitLib for more details. All notifications will be serviced
222 /// on an internal serial queue separate from the IO queue.
223 ///
224 /// Returns: An IOUSBHostDevice or IOUSBHostInterface. The object is to be released by the caller.
225 /// An IOReturn error code will be reported on failure.
226 ///
227 /// # Safety
228 ///
229 /// - `queue` possibly has additional threading requirements.
230 /// - `interest_handler` must be a valid pointer or null.
231 #[unsafe(method(initWithIOService:queue:error:interestHandler:))]
232 #[unsafe(method_family = init)]
233 pub unsafe fn initWithIOService_queue_error_interestHandler(
234 this: Allocated<Self>,
235 io_service: io_service_t,
236 queue: Option<&DispatchQueue>,
237 error: Option<&mut Option<Retained<NSError>>>,
238 interest_handler: IOUSBHostInterestHandler,
239 ) -> Option<Retained<Self>>;
240 );
241}
242
243/// Methods declared on superclass `NSObject`.
244#[cfg(feature = "IOUSBHostObject")]
245impl IOUSBHostDevice {
246 extern_methods!(
247 #[unsafe(method(new))]
248 #[unsafe(method_family = new)]
249 pub unsafe fn new() -> Retained<Self>;
250 );
251}