Debian Codegraph @

src/enumeration.rs

raw symbols SCIP
1 #[cfg(target_os = "windows")]
2 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::ffirust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/::{OsStrrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsStr#, OsStringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsString#};
3
4 #[cfg(any(target_os = "linux", target_os = "android"))]
5 use craterust-analyzer cargo nusb 0.1.13 crate/::platformrust-analyzer cargo nusb 0.1.13 platform/::SysfsPathrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/enumeration/SysfsPath#;
6
7 use craterust-analyzer cargo nusb 0.1.13 crate/::{Devicerust-analyzer cargo nusb 0.1.13 device/Device#, Errorrust-analyzer cargo nusb 0.1.13 Error#};
8
9 /// Opaque device identifier
10 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/macros/Hash:)]
11 pub struct DeviceIdrust-analyzer cargo nusb 0.1.13 enumeration/DeviceId#(pub(craterust-analyzer cargo nusb 0.1.13 crate/) craterust-analyzer cargo nusb 0.1.13 crate/::platformrust-analyzer cargo nusb 0.1.13 platform/::DeviceIdrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/DeviceId#);
12
13 /// Information about a device that can be obtained without opening it.
14 ///
15 /// Found in the results of [`crate::list_devices`].
16 ///
17 /// ### Platform-specific notes
18 ///
19 /// * Some fields are platform-specific
20 /// * Linux: `sysfs_path`
21 /// * Windows: `instance_id`, `parent_instance_id`, `port_number`, `driver`
22 /// * macOS: `registry_id`, `location_id`
23 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)]
24 pub struct DeviceInforust-analyzer cargo nusb 0.1.13 enumeration/DeviceInfo# {
25 #[cfg(any(target_os = "linux", target_os = "android"))]
26 pub(craterust-analyzer cargo nusb 0.1.13 crate/) pathrust-analyzer cargo nusb 0.1.13 enumeration/DeviceInfo#path.: SysfsPathrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/enumeration/SysfsPath#,
27
28 #[cfg(target_os = "windows")]
29 pub(craterust-analyzer cargo nusb 0.1.13 crate/) instance_id: OsString,
30
31 #[cfg(target_os = "windows")]
32 pub(craterust-analyzer cargo nusb 0.1.13 crate/) parent_instance_id: OsString,
33
34 #[cfg(target_os = "windows")]
35 pub(craterust-analyzer cargo nusb 0.1.13 crate/) port_number: u32,
36
37 #[cfg(target_os = "windows")]
38 pub(craterust-analyzer cargo nusb 0.1.13 crate/) devinst: craterust-analyzer cargo nusb 0.1.13 crate/::platformrust-analyzer cargo nusb 0.1.13 platform/::DevInst,
39
40 #[cfg(target_os = "windows")]
41 pub(craterust-analyzer cargo nusb 0.1.13 crate/) driver: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>,
42
43 #[cfg(target_os = "macos")]
44 pub(craterust-analyzer cargo nusb 0.1.13 crate/) registry_id: u64,
45
46 #[cfg(target_os = "macos")]
47 pub(craterust-analyzer cargo nusb 0.1.13 crate/) location_id: u32,
48
49 pub(craterust-analyzer cargo nusb 0.1.13 crate/) bus_numberrust-analyzer cargo nusb 0.1.13 enumeration/DeviceInfo#bus_number.: u8,
50 pub(craterust-analyzer cargo nusb 0.1.13 crate/) device_addressrust-analyzer cargo nusb 0.1.13 enumeration/DeviceInfo#device_address.: u8,
51
52 pub(craterust-analyzer cargo nusb 0.1.13 crate/) vendor_idrust-analyzer cargo nusb 0.1.13 enumeration/DeviceInfo#vendor_id.: u16,
53 pub(craterust-analyzer cargo nusb 0.1.13 crate/) product_idrust-analyzer cargo nusb 0.1.13 enumeration/DeviceInfo#product_id.: u16,
54 pub(craterust-analyzer cargo nusb 0.1.13 crate/) device_versionrust-analyzer cargo nusb 0.1.13 enumeration/DeviceInfo#device_version.: u16,
55
56 pub(craterust-analyzer cargo nusb 0.1.13 crate/) classrust-analyzer cargo nusb 0.1.13 enumeration/DeviceInfo#class.: u8,
57 pub(craterust-analyzer cargo nusb 0.1.13 crate/) subclassrust-analyzer cargo nusb 0.1.13 enumeration/DeviceInfo#subclass.: u8,
58 pub(craterust-analyzer cargo nusb 0.1.13 crate/) protocolrust-analyzer cargo nusb 0.1.13 enumeration/DeviceInfo#protocol.: u8,
59
60 pub(craterust-analyzer cargo nusb 0.1.13 crate/) speedrust-analyzer cargo nusb 0.1.13 enumeration/DeviceInfo#speed.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Speedrust-analyzer cargo nusb 0.1.13 enumeration/Speed#>,
61
62 pub(craterust-analyzer cargo nusb 0.1.13 crate/) manufacturer_stringrust-analyzer cargo nusb 0.1.13 enumeration/DeviceInfo#manufacturer_string.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>,
63 pub(craterust-analyzer cargo nusb 0.1.13 crate/) product_stringrust-analyzer cargo nusb 0.1.13 enumeration/DeviceInfo#product_string.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>,
64 pub(craterust-analyzer cargo nusb 0.1.13 crate/) serial_numberrust-analyzer cargo nusb 0.1.13 enumeration/DeviceInfo#serial_number.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>,
65
66 pub(craterust-analyzer cargo nusb 0.1.13 crate/) interfacesrust-analyzer cargo nusb 0.1.13 enumeration/DeviceInfo#interfaces.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<InterfaceInforust-analyzer cargo nusb 0.1.13 enumeration/InterfaceInfo#>,
67 }
68
69 impl DeviceInforust-analyzer cargo nusb 0.1.13 enumeration/DeviceInfo# {
70 /// Opaque identifier for the device.
71 pub fn idrust-analyzer cargo nusb 0.1.13 enumeration/impl#[DeviceInfo]id().(&self) -> DeviceIdrust-analyzer cargo nusb 0.1.13 enumeration/DeviceId# {
72 #[cfg(target_os = "windows")]
73 {
74 DeviceIdrust-analyzer cargo nusb 0.1.13 enumeration/DeviceId#(self.devinst)
75 }
76
77 #[cfg(any(target_os = "linux", target_os = "android"))]
78 {
79 DeviceIdrust-analyzer cargo nusb 0.1.13 enumeration/DeviceId#(craterust-analyzer cargo nusb 0.1.13 crate/::platformrust-analyzer cargo nusb 0.1.13 platform/::DeviceIdrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/DeviceId# {
80 busrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/DeviceId#bus.: self.bus_numberrust-analyzer cargo nusb 0.1.13 enumeration/DeviceInfo#bus_number.,
81 addrrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/DeviceId#addr.: self.device_addressrust-analyzer cargo nusb 0.1.13 enumeration/DeviceInfo#device_address.,
82 })
83 }
84
85 #[cfg(target_os = "macos")]
86 {
87 DeviceIdrust-analyzer cargo nusb 0.1.13 enumeration/DeviceId#(self.registry_id)
88 }
89 }
90
91 /// *(Linux-only)* Sysfs path for the device.
92 #[doc(hidden)]
93 #[deprecated = "use `sysfs_path()` instead"]
94 #[cfg(target_os = "linux")]
95 pub fn pathrust-analyzer cargo nusb 0.1.13 enumeration/impl#[DeviceInfo]path().(&self) -> &SysfsPathrust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/enumeration/SysfsPath# {
96 &self.pathrust-analyzer cargo nusb 0.1.13 enumeration/DeviceInfo#path.
97 }
98
99 /// *(Linux-only)* Sysfs path for the device.
100 #[cfg(any(target_os = "linux", target_os = "android"))]
101 pub fn sysfs_pathrust-analyzer cargo nusb 0.1.13 enumeration/impl#[DeviceInfo]sysfs_path().(&self) -> &stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path# {
102 &self.pathrust-analyzer cargo nusb 0.1.13 enumeration/DeviceInfo#path..0rust-analyzer cargo nusb 0.1.13 platform/linux_usbfs/enumeration/SysfsPath#0.
103 }
104
105 /// *(Windows-only)* Instance ID path of this device
106 #[cfg(target_os = "windows")]
107 pub fn instance_id(&self) -> &OsStr {
108 &selfrust-analyzer cargo nusb 0.1.13 enumeration/.instance_id
109 }
110
111 /// *(Windows-only)* Instance ID path of the parent hub
112 #[cfg(target_os = "windows")]
113 pub fn parent_instance_id(&self) -> &OsStr {
114 &selfrust-analyzer cargo nusb 0.1.13 enumeration/.parent_instance_id
115 }
116
117 /// *(Windows-only)* Port number
118 #[cfg(target_os = "windows")]
119 pub fn port_number(&self) -> u32 {
120 selfrust-analyzer cargo nusb 0.1.13 enumeration/.port_number
121 }
122
123 /// *(Windows-only)* Driver associated with the device as a whole
124 #[cfg(target_os = "windows")]
125 pub fn driver(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&str> {
126 selfrust-analyzer cargo nusb 0.1.13 enumeration/.driver.as_deref()
127 }
128
129 /// *(macOS-only)* IOKit Location ID
130 #[cfg(target_os = "macos")]
131 pub fn location_id(&self) -> u32 {
132 selfrust-analyzer cargo nusb 0.1.13 enumeration/.location_id
133 }
134
135 /// *(macOS-only)* IOKit [Registry Entry ID](https://developer.apple.com/documentation/iokit/1514719-ioregistryentrygetregistryentryi?language=objc)
136 #[cfg(target_os = "macos")]
137 pub fn registry_entry_id(&self) -> u64 {
138 selfrust-analyzer cargo nusb 0.1.13 enumeration/.registry_id
139 }
140
141 /// Number identifying the bus / host controller where the device is connected.
142 pub fn bus_numberrust-analyzer cargo nusb 0.1.13 enumeration/impl#[DeviceInfo]bus_number().(&self) -> u8 {
143 self.bus_numberrust-analyzer cargo nusb 0.1.13 enumeration/DeviceInfo#bus_number.
144 }
145
146 /// Number identifying the device within the bus.
147 pub fn device_addressrust-analyzer cargo nusb 0.1.13 enumeration/impl#[DeviceInfo]device_address().(&self) -> u8 {
148 self.device_addressrust-analyzer cargo nusb 0.1.13 enumeration/DeviceInfo#device_address.
149 }
150
151 /// The 16-bit number identifying the device's vendor, from the `idVendor` device descriptor field.
152 #[doc(alias = "idVendor")]
153 pub fn vendor_idrust-analyzer cargo nusb 0.1.13 enumeration/impl#[DeviceInfo]vendor_id().(&self) -> u16 {
154 self.vendor_idrust-analyzer cargo nusb 0.1.13 enumeration/DeviceInfo#vendor_id.
155 }
156
157 /// The 16-bit number identifying the product, from the `idProduct` device descriptor field.
158 #[doc(alias = "idProduct")]
159 pub fn product_idrust-analyzer cargo nusb 0.1.13 enumeration/impl#[DeviceInfo]product_id().(&self) -> u16 {
160 self.product_idrust-analyzer cargo nusb 0.1.13 enumeration/DeviceInfo#product_id.
161 }
162
163 /// The device version, normally encoded as BCD, from the `bcdDevice` device descriptor field.
164 #[doc(alias = "bcdDevice")]
165 pub fn device_versionrust-analyzer cargo nusb 0.1.13 enumeration/impl#[DeviceInfo]device_version().(&self) -> u16 {
166 self.device_versionrust-analyzer cargo nusb 0.1.13 enumeration/DeviceInfo#device_version.
167 }
168
169 /// Code identifying the standard device class, from the `bDeviceClass` device descriptor field.
170 ///
171 /// `0x00`: specified at the interface level.\
172 /// `0xFF`: vendor-defined.
173 #[doc(alias = "bDeviceClass")]
174 pub fn classrust-analyzer cargo nusb 0.1.13 enumeration/impl#[DeviceInfo]class().(&self) -> u8 {
175 self.classrust-analyzer cargo nusb 0.1.13 enumeration/DeviceInfo#class.
176 }
177
178 /// Standard subclass, from the `bDeviceSubClass` device descriptor field.
179 #[doc(alias = "bDeviceSubClass")]
180 pub fn subclassrust-analyzer cargo nusb 0.1.13 enumeration/impl#[DeviceInfo]subclass().(&self) -> u8 {
181 self.subclassrust-analyzer cargo nusb 0.1.13 enumeration/DeviceInfo#subclass.
182 }
183
184 /// Standard protocol, from the `bDeviceProtocol` device descriptor field.
185 #[doc(alias = "bDeviceProtocol")]
186 pub fn protocolrust-analyzer cargo nusb 0.1.13 enumeration/impl#[DeviceInfo]protocol().(&self) -> u8 {
187 self.protocolrust-analyzer cargo nusb 0.1.13 enumeration/DeviceInfo#protocol.
188 }
189
190 /// Connection speed
191 pub fn speedrust-analyzer cargo nusb 0.1.13 enumeration/impl#[DeviceInfo]speed().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Speedrust-analyzer cargo nusb 0.1.13 enumeration/Speed#> {
192 self.speedrust-analyzer cargo nusb 0.1.13 enumeration/DeviceInfo#speed.
193 }
194
195 /// Manufacturer string, if available without device IO.
196 ///
197 /// ### Platform-specific notes
198 /// * Windows: Windows does not cache the manufacturer string, and
199 /// this will return `None` regardless of whether a descriptor exists.
200 #[doc(alias = "iManufacturer")]
201 pub fn manufacturer_stringrust-analyzer cargo nusb 0.1.13 enumeration/impl#[DeviceInfo]manufacturer_string().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&str> {
202 self.manufacturer_stringrust-analyzer cargo nusb 0.1.13 enumeration/DeviceInfo#manufacturer_string..as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().()
203 }
204
205 /// Product string, if available without device IO.
206 #[doc(alias = "iProduct")]
207 pub fn product_stringrust-analyzer cargo nusb 0.1.13 enumeration/impl#[DeviceInfo]product_string().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&str> {
208 self.product_stringrust-analyzer cargo nusb 0.1.13 enumeration/DeviceInfo#product_string..as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().()
209 }
210
211 /// Serial number string, if available without device IO.
212 #[doc(alias = "iSerial")]
213 pub fn serial_numberrust-analyzer cargo nusb 0.1.13 enumeration/impl#[DeviceInfo]serial_number().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&str> {
214 self.serial_numberrust-analyzer cargo nusb 0.1.13 enumeration/DeviceInfo#serial_number..as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().()
215 }
216
217 /// Iterator over the device's interfaces.
218 ///
219 /// This returns summary information about the interfaces in the device's
220 /// active configuration for the purposes of matching devices prior to
221 /// opening them.
222 ///
223 /// Additional information about interfaces can be found in the
224 /// configuration descriptor after opening the device by calling
225 /// [`Device::active_configuration`].
226 ///
227 /// ### Platform-specific notes:
228 /// * Windows: this is only available for composite devices bound to the
229 /// `usbccgp` driver, and will be empty if the entire device is bound to
230 /// a specific driver.
231 /// * Windows: When interfaces are grouped by an interface
232 /// association descriptor, this returns details from the interface
233 /// association descriptor and does not include each of the associated
234 /// interfaces.
235 pub fn interfacesrust-analyzer cargo nusb 0.1.13 enumeration/impl#[DeviceInfo]interfaces().(&self) -> impl Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = &InterfaceInforust-analyzer cargo nusb 0.1.13 enumeration/InterfaceInfo#> {
236 self.interfacesrust-analyzer cargo nusb 0.1.13 enumeration/DeviceInfo#interfaces..iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()
237 }
238
239 /// Open the device
240 pub fn openrust-analyzer cargo nusb 0.1.13 enumeration/impl#[DeviceInfo]open().(&self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Devicerust-analyzer cargo nusb 0.1.13 device/Device#, Errorrust-analyzer cargo nusb 0.1.13 Error#> {
241 Devicerust-analyzer cargo nusb 0.1.13 device/Device#::openrust-analyzer cargo nusb 0.1.13 device/impl#[Device]open().(self)
242 }
243 }
244
245 // Not derived so that we can format some fields in hex
246 impl stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# for DeviceInforust-analyzer cargo nusb 0.1.13 enumeration/DeviceInfo# {
247 fn fmtrust-analyzer cargo nusb 0.1.13 enumeration/impl#[DeviceInfo][Debug]fmt().(&self, f: &mut stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# {
248 let mut s = f.debug_structrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]debug_struct().("DeviceInfo");
249
250 s.fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("bus_number", &self.bus_numberrust-analyzer cargo nusb 0.1.13 enumeration/DeviceInfo#bus_number.)
251 .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("device_address", &self.device_addressrust-analyzer cargo nusb 0.1.13 enumeration/DeviceInfo#device_address.)
252 .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("vendor_id", &format_argsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/format_args!!("0x{:04X}", self.vendor_idrust-analyzer cargo nusb 0.1.13 enumeration/DeviceInfo#vendor_id.))
253 .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("product_id", &format_argsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/format_args!!("0x{:04X}", self.product_idrust-analyzer cargo nusb 0.1.13 enumeration/DeviceInfo#product_id.))
254 .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().(
255 "device_version",
256 &format_argsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/format_args!!("0x{:04X}", self.device_versionrust-analyzer cargo nusb 0.1.13 enumeration/DeviceInfo#device_version.),
257 )
258 .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("class", &format_argsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/format_args!!("0x{:02X}", self.classrust-analyzer cargo nusb 0.1.13 enumeration/DeviceInfo#class.))
259 .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("subclass", &format_argsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/format_args!!("0x{:02X}", self.subclassrust-analyzer cargo nusb 0.1.13 enumeration/DeviceInfo#subclass.))
260 .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("protocol", &format_argsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/format_args!!("0x{:02X}", self.protocolrust-analyzer cargo nusb 0.1.13 enumeration/DeviceInfo#protocol.))
261 .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("speed", &self.speedrust-analyzer cargo nusb 0.1.13 enumeration/DeviceInfo#speed.)
262 .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("manufacturer_string", &self.manufacturer_stringrust-analyzer cargo nusb 0.1.13 enumeration/DeviceInfo#manufacturer_string.)
263 .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("product_string", &self.product_stringrust-analyzer cargo nusb 0.1.13 enumeration/DeviceInfo#product_string.)
264 .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("serial_number", &self.serial_numberrust-analyzer cargo nusb 0.1.13 enumeration/DeviceInfo#serial_number.);
265
266 #[cfg(any(target_os = "linux", target_os = "android"))]
267 {
268 s.fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("sysfs_path", &self.pathrust-analyzer cargo nusb 0.1.13 enumeration/DeviceInfo#path.);
269 }
270
271 #[cfg(target_os = "windows")]
272 {
273 s.field("instance_id", &self.instance_id);
274 s.field("parent_instance_id", &self.parent_instance_id);
275 s.field("port_number", &self.port_number);
276 s.field("driver", &self.driver);
277 }
278
279 #[cfg(target_os = "macos")]
280 {
281 s.field("location_id", &format_argsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/format_args!!("0x{:08X}", self.location_id));
282 s.field(
283 "registry_entry_id",
284 &format_argsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/format_args!!("0x{:08X}", self.registry_id),
285 );
286 }
287
288 s.fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("interfaces", &self.interfacesrust-analyzer cargo nusb 0.1.13 enumeration/DeviceInfo#interfaces.);
289
290 s.finishrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]finish().()
291 }
292 }
293
294 /// USB connection speed
295 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:, Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/macros/Hash:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)]
296 #[non_exhaustive]
297 pub enum Speedrust-analyzer cargo nusb 0.1.13 enumeration/Speed# {
298 /// Low speed (1.5 Mbit)
299 Lowrust-analyzer cargo nusb 0.1.13 enumeration/Speed#Low#,
300
301 /// Full speed (12 Mbit)
302 Fullrust-analyzer cargo nusb 0.1.13 enumeration/Speed#Full#,
303
304 /// High speed (480 Mbit)
305 Highrust-analyzer cargo nusb 0.1.13 enumeration/Speed#High#,
306
307 /// Super speed (5000 Mbit)
308 Superrust-analyzer cargo nusb 0.1.13 enumeration/Speed#Super#,
309
310 /// Super speed (10000 Mbit)
311 SuperPlusrust-analyzer cargo nusb 0.1.13 enumeration/Speed#SuperPlus#,
312 }
313
314 impl Speedrust-analyzer cargo nusb 0.1.13 enumeration/Speed# {
315 #[allow(dead_code)] // not used on all platforms
316 pub(craterust-analyzer cargo nusb 0.1.13 crate/) fn from_strrust-analyzer cargo nusb 0.1.13 enumeration/impl#[Speed]from_str().(s: &str) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Selfrust-analyzer cargo nusb 0.1.13 enumeration/impl#[Speed]> {
317 match s {
318 "low" | "1.5" => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Speedrust-analyzer cargo nusb 0.1.13 enumeration/Speed#::Lowrust-analyzer cargo nusb 0.1.13 enumeration/Speed#Low#),
319 "full" | "12" => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Speedrust-analyzer cargo nusb 0.1.13 enumeration/Speed#::Fullrust-analyzer cargo nusb 0.1.13 enumeration/Speed#Full#),
320 "high" | "480" => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Speedrust-analyzer cargo nusb 0.1.13 enumeration/Speed#::Highrust-analyzer cargo nusb 0.1.13 enumeration/Speed#High#),
321 "super" | "5000" => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Speedrust-analyzer cargo nusb 0.1.13 enumeration/Speed#::Superrust-analyzer cargo nusb 0.1.13 enumeration/Speed#Super#),
322 "super+" | "10000" => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Speedrust-analyzer cargo nusb 0.1.13 enumeration/Speed#::SuperPlusrust-analyzer cargo nusb 0.1.13 enumeration/Speed#SuperPlus#),
323 _ => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
324 }
325 }
326 }
327
328 /// Summary information about a device's interface, available before opening a device.
329 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)]
330 pub struct InterfaceInforust-analyzer cargo nusb 0.1.13 enumeration/InterfaceInfo# {
331 pub(craterust-analyzer cargo nusb 0.1.13 crate/) interface_numberrust-analyzer cargo nusb 0.1.13 enumeration/InterfaceInfo#interface_number.: u8,
332 pub(craterust-analyzer cargo nusb 0.1.13 crate/) classrust-analyzer cargo nusb 0.1.13 enumeration/InterfaceInfo#class.: u8,
333 pub(craterust-analyzer cargo nusb 0.1.13 crate/) subclassrust-analyzer cargo nusb 0.1.13 enumeration/InterfaceInfo#subclass.: u8,
334 pub(craterust-analyzer cargo nusb 0.1.13 crate/) protocolrust-analyzer cargo nusb 0.1.13 enumeration/InterfaceInfo#protocol.: u8,
335 pub(craterust-analyzer cargo nusb 0.1.13 crate/) interface_stringrust-analyzer cargo nusb 0.1.13 enumeration/InterfaceInfo#interface_string.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>,
336 }
337
338 impl InterfaceInforust-analyzer cargo nusb 0.1.13 enumeration/InterfaceInfo# {
339 /// Identifier for the interface from the `bInterfaceNumber` descriptor field.
340 pub fn interface_numberrust-analyzer cargo nusb 0.1.13 enumeration/impl#[InterfaceInfo]interface_number().(&self) -> u8 {
341 self.interface_numberrust-analyzer cargo nusb 0.1.13 enumeration/InterfaceInfo#interface_number.
342 }
343
344 /// Code identifying the standard interface class, from the `bInterfaceClass` interface descriptor field.
345 pub fn classrust-analyzer cargo nusb 0.1.13 enumeration/impl#[InterfaceInfo]class().(&self) -> u8 {
346 self.classrust-analyzer cargo nusb 0.1.13 enumeration/InterfaceInfo#class.
347 }
348
349 /// Standard subclass, from the `bInterfaceSubClass` interface descriptor field.
350 pub fn subclassrust-analyzer cargo nusb 0.1.13 enumeration/impl#[InterfaceInfo]subclass().(&self) -> u8 {
351 self.subclassrust-analyzer cargo nusb 0.1.13 enumeration/InterfaceInfo#subclass.
352 }
353
354 /// Standard protocol, from the `bInterfaceProtocol` interface descriptor field.
355 pub fn protocolrust-analyzer cargo nusb 0.1.13 enumeration/impl#[InterfaceInfo]protocol().(&self) -> u8 {
356 self.protocolrust-analyzer cargo nusb 0.1.13 enumeration/InterfaceInfo#protocol.
357 }
358
359 /// Interface string descriptor value as cached by the OS.
360 pub fn interface_stringrust-analyzer cargo nusb 0.1.13 enumeration/impl#[InterfaceInfo]interface_string().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&str> {
361 self.interface_stringrust-analyzer cargo nusb 0.1.13 enumeration/InterfaceInfo#interface_string..as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().()
362 }
363 }
364
365 // Not derived so that we can format some fields in hex
366 impl stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# for InterfaceInforust-analyzer cargo nusb 0.1.13 enumeration/InterfaceInfo# {
367 fn fmtrust-analyzer cargo nusb 0.1.13 enumeration/impl#[InterfaceInfo][Debug]fmt().(&self, f: &mut stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# {
368 f.debug_structrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]debug_struct().("InterfaceInfo")
369 .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("interface_number", &self.interface_numberrust-analyzer cargo nusb 0.1.13 enumeration/InterfaceInfo#interface_number.)
370 .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("class", &format_argsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/format_args!!("0x{:02X}", self.classrust-analyzer cargo nusb 0.1.13 enumeration/InterfaceInfo#class.))
371 .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("subclass", &format_argsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/format_args!!("0x{:02X}", self.subclassrust-analyzer cargo nusb 0.1.13 enumeration/InterfaceInfo#subclass.))
372 .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("protocol", &format_argsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/format_args!!("0x{:02X}", self.protocolrust-analyzer cargo nusb 0.1.13 enumeration/InterfaceInfo#protocol.))
373 .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("interface_string", &self.interface_stringrust-analyzer cargo nusb 0.1.13 enumeration/InterfaceInfo#interface_string.)
374 .finishrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]finish().()
375 }
376 }