| 1 | //! Utilities for parsing USB descriptors. |
| 2 | //! |
| 3 | //! Descriptors are blocks of data that describe the functionality of a USB device. |
| 4 | |
| 5 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::{ |
| 6 | collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#, |
| 7 | 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#, Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display#}, |
| 8 | iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::ErrorKindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#, |
| 9 | iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/, |
| 10 | opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::Derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#, |
| 11 | }; |
| 12 | |
| 13 | use logrust-analyzer cargo log 0.4.34 crate/::warnrust-analyzer cargo log 0.4.34 macros/warn!; |
| 14 | |
| 15 | use craterust-analyzer cargo nusb 0.1.13 crate/::{ |
| 16 | transferrust-analyzer cargo nusb 0.1.13 transfer/::{Directionrust-analyzer cargo nusb 0.1.13 transfer/control/Direction#, EndpointTyperust-analyzer cargo nusb 0.1.13 transfer/EndpointType#}, |
| 17 | Errorrust-analyzer cargo nusb 0.1.13 Error#, |
| 18 | }; |
| 19 | |
| 20 | #[allow(dead_code)] |
| 21 | pub(craterust-analyzer cargo nusb 0.1.13 crate/) const DESCRIPTOR_TYPE_DEVICErust-analyzer cargo nusb 0.1.13 descriptors/DESCRIPTOR_TYPE_DEVICE.: u8 = 0x01; |
| 22 | pub(craterust-analyzer cargo nusb 0.1.13 crate/) const DESCRIPTOR_LEN_DEVICErust-analyzer cargo nusb 0.1.13 descriptors/DESCRIPTOR_LEN_DEVICE.: u8 = 18; |
| 23 | |
| 24 | pub(craterust-analyzer cargo nusb 0.1.13 crate/) const DESCRIPTOR_TYPE_CONFIGURATIONrust-analyzer cargo nusb 0.1.13 descriptors/DESCRIPTOR_TYPE_CONFIGURATION.: u8 = 0x02; |
| 25 | pub(craterust-analyzer cargo nusb 0.1.13 crate/) const DESCRIPTOR_LEN_CONFIGURATIONrust-analyzer cargo nusb 0.1.13 descriptors/DESCRIPTOR_LEN_CONFIGURATION.: u8 = 9; |
| 26 | |
| 27 | pub(craterust-analyzer cargo nusb 0.1.13 crate/) const DESCRIPTOR_TYPE_INTERFACErust-analyzer cargo nusb 0.1.13 descriptors/DESCRIPTOR_TYPE_INTERFACE.: u8 = 0x04; |
| 28 | pub(craterust-analyzer cargo nusb 0.1.13 crate/) const DESCRIPTOR_LEN_INTERFACErust-analyzer cargo nusb 0.1.13 descriptors/DESCRIPTOR_LEN_INTERFACE.: u8 = 9; |
| 29 | |
| 30 | pub(craterust-analyzer cargo nusb 0.1.13 crate/) const DESCRIPTOR_TYPE_ENDPOINTrust-analyzer cargo nusb 0.1.13 descriptors/DESCRIPTOR_TYPE_ENDPOINT.: u8 = 0x05; |
| 31 | pub(craterust-analyzer cargo nusb 0.1.13 crate/) const DESCRIPTOR_LEN_ENDPOINTrust-analyzer cargo nusb 0.1.13 descriptors/DESCRIPTOR_LEN_ENDPOINT.: u8 = 7; |
| 32 | |
| 33 | pub(craterust-analyzer cargo nusb 0.1.13 crate/) const DESCRIPTOR_TYPE_STRINGrust-analyzer cargo nusb 0.1.13 descriptors/DESCRIPTOR_TYPE_STRING.: u8 = 0x03; |
| 34 | |
| 35 | /// USB defined language IDs for string descriptors. |
| 36 | /// |
| 37 | /// In practice, different language IDs are not used, |
| 38 | /// and device string descriptors are only provided |
| 39 | /// with [`language_id::US_ENGLISH`]. |
| 40 | pub mod language_idrust-analyzer cargo nusb 0.1.13 descriptors/language_id/ { |
| 41 | /// US English |
| 42 | pub const US_ENGLISHrust-analyzer cargo nusb 0.1.13 descriptors/language_id/US_ENGLISH.: u16 = 0x0409; |
| 43 | } |
| 44 | |
| 45 | /// A raw USB descriptor. |
| 46 | /// |
| 47 | /// Wraps a byte slice to provide access to the bytes of a descriptor by implementing `Deref` to `[u8]`, |
| 48 | /// while also exposing the descriptor length and type. |
| 49 | #[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:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, 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:)] |
| 50 | pub struct Descriptorrust-analyzer cargo nusb 0.1.13 descriptors/Descriptor#<'a>(&'a [u8]); |
| 51 | |
| 52 | impl<'a> Descriptorrust-analyzer cargo nusb 0.1.13 descriptors/Descriptor#<'a> { |
| 53 | /// Create a `Descriptor` from a buffer. |
| 54 | /// |
| 55 | /// Returns `None` if |
| 56 | /// * the slice length is not at least 2. |
| 57 | /// * the `bLength` field (first byte) is greater than the slice length. |
| 58 | pub fn newrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Descriptor<'a>`]new().(buf: &[u8]) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Descriptorrust-analyzer cargo nusb 0.1.13 descriptors/Descriptor#> { |
| 59 | if buf.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().2 && buf.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). as usize { |
| 60 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Descriptorrust-analyzer cargo nusb 0.1.13 descriptors/Descriptor#(buf)) |
| 61 | } else { |
| 62 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | /// Get the length field of the descriptor. |
| 67 | #[doc(alias = "bLength")] |
| 68 | pub fn descriptor_lenrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Descriptor<'a>`]descriptor_len().(&self) -> usize { |
| 69 | self.0rust-analyzer cargo nusb 0.1.13 descriptors/Descriptor#0.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). as usize |
| 70 | } |
| 71 | |
| 72 | /// Get the type field of the descriptor. |
| 73 | #[doc(alias = "bDescriptorType")] |
| 74 | pub fn descriptor_typerust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Descriptor<'a>`]descriptor_type().(&self) -> u8 { |
| 75 | self.0rust-analyzer cargo nusb 0.1.13 descriptors/Descriptor#0.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | impl<'a> Derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref# for Descriptorrust-analyzer cargo nusb 0.1.13 descriptors/Descriptor#<'a> { |
| 80 | type Targetrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Descriptor<'a>`][Deref]Target# = [u8]; |
| 81 | |
| 82 | fn derefrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Descriptor<'a>`][Deref]deref().(&self) -> &[u8] { |
| 83 | self.0rust-analyzer cargo nusb 0.1.13 descriptors/Descriptor#0. |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | /// An iterator over a sequence of USB descriptors. |
| 88 | #[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:)] |
| 89 | pub struct Descriptorsrust-analyzer cargo nusb 0.1.13 descriptors/Descriptors#<'a>(&'a [u8]); |
| 90 | |
| 91 | impl<'a> Descriptorsrust-analyzer cargo nusb 0.1.13 descriptors/Descriptors#<'a> { |
| 92 | /// Get the concatenated bytes of the remaining descriptors. |
| 93 | pub fn as_bytesrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Descriptors<'a>`]as_bytes().(&self) -> &'a [u8] { |
| 94 | self.0rust-analyzer cargo nusb 0.1.13 descriptors/Descriptors#0. |
| 95 | } |
| 96 | |
| 97 | fn split_firstrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Descriptors<'a>`]split_first().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<(&'a [u8], &'a [u8])> { |
| 98 | if self.0rust-analyzer cargo nusb 0.1.13 descriptors/Descriptors#0..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().2 { |
| 99 | return Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 100 | } |
| 101 | |
| 102 | if self.0rust-analyzer cargo nusb 0.1.13 descriptors/Descriptors#0.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]lt().2 { |
| 103 | warnrust-analyzer cargo log 0.4.34 macros/warn!!( |
| 104 | "descriptor with bLength {} can't point to next descriptor", |
| 105 | self.0rust-analyzer cargo nusb 0.1.13 descriptors/Descriptors#0.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). |
| 106 | ); |
| 107 | return Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 108 | } |
| 109 | |
| 110 | if self.0rust-analyzer cargo nusb 0.1.13 descriptors/Descriptors#0.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). as usize rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().self.0rust-analyzer cargo nusb 0.1.13 descriptors/Descriptors#0..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() { |
| 111 | warnrust-analyzer cargo log 0.4.34 macros/warn!!( |
| 112 | "descriptor with bLength {} exceeds remaining buffer length {}", |
| 113 | self.0rust-analyzer cargo nusb 0.1.13 descriptors/Descriptors#0.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., |
| 114 | self.0rust-analyzer cargo nusb 0.1.13 descriptors/Descriptors#0..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() |
| 115 | ); |
| 116 | return Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 117 | } |
| 118 | |
| 119 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(self.0rust-analyzer cargo nusb 0.1.13 descriptors/Descriptors#0..split_atrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]split_at().(self.0rust-analyzer cargo nusb 0.1.13 descriptors/Descriptors#0.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). as usize)) |
| 120 | } |
| 121 | |
| 122 | fn split_by_typerust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Descriptors<'a>`]split_by_type().(mut self, descriptor_type: u8, min_len: u8) -> 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# = &'a [u8]> { |
| 123 | iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::from_fnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/sources/from_fn/from_fn().(move || { |
| 124 | loop { |
| 125 | let (_, next) = self.split_firstrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Descriptors<'a>`]split_first().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch().; |
| 126 | |
| 127 | if self.0rust-analyzer cargo nusb 0.1.13 descriptors/Descriptors#0.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().descriptor_type { |
| 128 | if self.0rust-analyzer cargo nusb 0.1.13 descriptors/Descriptors#0.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]ge().min_len { |
| 129 | break; |
| 130 | } else { |
| 131 | warnrust-analyzer cargo log 0.4.34 macros/warn!!("ignoring descriptor of type {} and length {} because the minimum length is {}", self.0rust-analyzer cargo nusb 0.1.13 descriptors/Descriptors#0.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., self.0rust-analyzer cargo nusb 0.1.13 descriptors/Descriptors#0.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., min_len); |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | self.0rust-analyzer cargo nusb 0.1.13 descriptors/Descriptors#0. = next; |
| 136 | } |
| 137 | |
| 138 | let mut end = self.0rust-analyzer cargo nusb 0.1.13 descriptors/Descriptors#0.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). as usize; |
| 139 | |
| 140 | while self.0rust-analyzer cargo nusb 0.1.13 descriptors/Descriptors#0..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().end rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().2 |
| 141 | && self.0rust-analyzer cargo nusb 0.1.13 descriptors/Descriptors#0.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().end]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]gt().2 |
| 142 | && self.0rust-analyzer cargo nusb 0.1.13 descriptors/Descriptors#0.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().end rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().descriptor_type |
| 143 | && self.0rust-analyzer cargo nusb 0.1.13 descriptors/Descriptors#0..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().end rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().self.0rust-analyzer cargo nusb 0.1.13 descriptors/Descriptors#0.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().end]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). as usize |
| 144 | { |
| 145 | end rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().self.0rust-analyzer cargo nusb 0.1.13 descriptors/Descriptors#0.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().end]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). as usize; |
| 146 | } |
| 147 | |
| 148 | let (r, next) = self.0rust-analyzer cargo nusb 0.1.13 descriptors/Descriptors#0..split_atrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]split_at().(end); |
| 149 | self.0rust-analyzer cargo nusb 0.1.13 descriptors/Descriptors#0. = next; |
| 150 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(r) |
| 151 | }) |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | impl<'a> Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for Descriptorsrust-analyzer cargo nusb 0.1.13 descriptors/Descriptors#<'a> { |
| 156 | type Itemrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Descriptors<'a>`][Iterator]Item# = Descriptorrust-analyzer cargo nusb 0.1.13 descriptors/Descriptor#<'a>; |
| 157 | |
| 158 | fn nextrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Descriptors<'a>`][Iterator]next().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Selfrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Descriptors<'a>`][Iterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> { |
| 159 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((cur, next)) = self.split_firstrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Descriptors<'a>`]split_first().() { |
| 160 | self.0rust-analyzer cargo nusb 0.1.13 descriptors/Descriptors#0. = next; |
| 161 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Descriptorrust-analyzer cargo nusb 0.1.13 descriptors/Descriptor#(cur)) |
| 162 | } else { |
| 163 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 164 | } |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | macro_rules! descriptor_fieldsrust-analyzer cargo nusb 0.1.13 descriptors/descriptor_fields! { |
| 169 | (impl<'a> $tname:ident<'a> { |
| 170 | $( |
| 171 | $(#[$attr:meta])* |
| 172 | $vis:vis fn $name:ident at $pos:literal -> $ty:ty; |
| 173 | )* |
| 174 | }) => { |
| 175 | impl<'a> $tname<'a> { |
| 176 | $( |
| 177 | $(#[$attr])* |
| 178 | #[inline] |
| 179 | $vis fn $name(&self) -> $ty { <$ty>::from_le_bytes(self.0[$pos..$pos + std::mem::size_of::<$ty>()].try_into().unwrap()) } |
| 180 | )* |
| 181 | } |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | pub(craterust-analyzer cargo nusb 0.1.13 crate/) fn validate_config_descriptorrust-analyzer cargo nusb 0.1.13 descriptors/validate_config_descriptor().(buf: &[u8]) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize> { |
| 186 | if buf.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().DESCRIPTOR_LEN_CONFIGURATIONrust-analyzer cargo nusb 0.1.13 descriptors/DESCRIPTOR_LEN_CONFIGURATION. as usize { |
| 187 | if buf.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().0 { |
| 188 | warnrust-analyzer cargo log 0.4.34 macros/warn!!( |
| 189 | "config descriptor buffer is {} bytes, need {}", |
| 190 | buf.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), |
| 191 | DESCRIPTOR_LEN_CONFIGURATIONrust-analyzer cargo nusb 0.1.13 descriptors/DESCRIPTOR_LEN_CONFIGURATION. |
| 192 | ); |
| 193 | } |
| 194 | return Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 195 | } |
| 196 | |
| 197 | if buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]lt().DESCRIPTOR_LEN_CONFIGURATIONrust-analyzer cargo nusb 0.1.13 descriptors/DESCRIPTOR_LEN_CONFIGURATION. { |
| 198 | warnrust-analyzer cargo log 0.4.34 macros/warn!!("invalid config descriptor bLength"); |
| 199 | return Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 200 | } |
| 201 | |
| 202 | if buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().DESCRIPTOR_TYPE_CONFIGURATIONrust-analyzer cargo nusb 0.1.13 descriptors/DESCRIPTOR_TYPE_CONFIGURATION. { |
| 203 | warnrust-analyzer cargo log 0.4.34 macros/warn!!( |
| 204 | "config bDescriptorType is {}, not a configuration descriptor", |
| 205 | buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). |
| 206 | ); |
| 207 | return Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 208 | } |
| 209 | |
| 210 | let total_len = u16::from_le_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u16]from_le_bytes().(buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().2..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#4]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryInto#try_into().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()) as usize; |
| 211 | if total_len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). as usize || total_len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().buf.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() { |
| 212 | warnrust-analyzer cargo log 0.4.34 macros/warn!!( |
| 213 | "invalid config descriptor wTotalLen of {total_len} (buffer size is {bufsize})", |
| 214 | bufsize = buf.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() |
| 215 | ); |
| 216 | return Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 217 | } |
| 218 | |
| 219 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(total_len) |
| 220 | } |
| 221 | |
| 222 | /// Information about a USB configuration with access to all associated interfaces, endpoints, and other descriptors. |
| 223 | #[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:)] |
| 224 | pub struct Configurationrust-analyzer cargo nusb 0.1.13 descriptors/Configuration#<'a>(&'a [u8]); |
| 225 | |
| 226 | impl<'a> Configurationrust-analyzer cargo nusb 0.1.13 descriptors/Configuration#<'a> { |
| 227 | /// Create a `Configuration` from a buffer containing a series of descriptors. |
| 228 | /// |
| 229 | /// You normally obtain a `Configuration` from a [`Device`][crate::Device], but this allows creating |
| 230 | /// one from your own descriptor bytes for tests. |
| 231 | /// |
| 232 | /// ### Panics |
| 233 | /// * when the buffer is too short for a configuration descriptor |
| 234 | /// * when the bLength and wTotalLength fields are longer than the buffer |
| 235 | /// * when the first descriptor is not a configuration descriptor |
| 236 | pub fn newrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Configuration<'a>`]new().(buf: &[u8]) -> Configurationrust-analyzer cargo nusb 0.1.13 descriptors/Configuration# { |
| 237 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(buf.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() >= DESCRIPTOR_LEN_CONFIGURATIONrust-analyzer cargo nusb 0.1.13 descriptors/DESCRIPTOR_LEN_CONFIGURATION. as usize); |
| 238 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). as usize >= DESCRIPTOR_LEN_CONFIGURATIONrust-analyzer cargo nusb 0.1.13 descriptors/DESCRIPTOR_LEN_CONFIGURATION. as usize); |
| 239 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). == DESCRIPTOR_TYPE_CONFIGURATIONrust-analyzer cargo nusb 0.1.13 descriptors/DESCRIPTOR_TYPE_CONFIGURATION.); |
| 240 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(buf.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() == u16::from_le_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u16]from_le_bytes().(buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().2..4]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryInto#try_into().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()) as usize); |
| 241 | Configurationrust-analyzer cargo nusb 0.1.13 descriptors/Configuration#(buf) |
| 242 | } |
| 243 | |
| 244 | /// Get the configuration descriptor followed by all trailing interface and other descriptors. |
| 245 | pub fn descriptorsrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Configuration<'a>`]descriptors().(&self) -> Descriptorsrust-analyzer cargo nusb 0.1.13 descriptors/Descriptors#<'a> { |
| 246 | Descriptorsrust-analyzer cargo nusb 0.1.13 descriptors/Descriptors#(self.0rust-analyzer cargo nusb 0.1.13 descriptors/Configuration#0.) |
| 247 | } |
| 248 | |
| 249 | /// Iterate all interfaces and alternate settings settings of this configuration. |
| 250 | pub fn interface_alt_settingsrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Configuration<'a>`]interface_alt_settings().(&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# = InterfaceAltSettingrust-analyzer cargo nusb 0.1.13 descriptors/InterfaceAltSetting#<'a>> { |
| 251 | self.descriptorsrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Configuration<'a>`]descriptors().() |
| 252 | .split_by_typerust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Descriptors<'a>`]split_by_type().(DESCRIPTOR_TYPE_INTERFACErust-analyzer cargo nusb 0.1.13 descriptors/DESCRIPTOR_TYPE_INTERFACE., DESCRIPTOR_LEN_INTERFACErust-analyzer cargo nusb 0.1.13 descriptors/DESCRIPTOR_LEN_INTERFACE.) |
| 253 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(InterfaceAltSettingrust-analyzer cargo nusb 0.1.13 descriptors/InterfaceAltSetting#) |
| 254 | } |
| 255 | |
| 256 | /// Iterate the interfaces of this configuration, grouping together alternate settings of the same interface. |
| 257 | pub fn interfacesrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Configuration<'a>`]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# = InterfaceGrouprust-analyzer cargo nusb 0.1.13 descriptors/InterfaceGroup#<'a>> { |
| 258 | let mut interfaces = BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V>`]new().(); |
| 259 | |
| 260 | for intf in self.interface_alt_settingsrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Configuration<'a>`]interface_alt_settings().() { |
| 261 | interfaces |
| 262 | .entryrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]entry().(intf.interface_numberrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]interface_number().()) |
| 263 | .or_insert_withrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/entry/impl#[`Entry<'a, K, V, A>`]or_insert_with().(Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().) |
| 264 | .pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(intf); |
| 265 | } |
| 266 | |
| 267 | interfaces |
| 268 | .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`][IntoIterator]into_iter().() |
| 269 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|(intf_number, interfaces)| InterfaceGrouprust-analyzer cargo nusb 0.1.13 descriptors/InterfaceGroup# { |
| 270 | intf_numberrust-analyzer cargo nusb 0.1.13 descriptors/InterfaceGroup#intf_number., |
| 271 | interfacesrust-analyzer cargo nusb 0.1.13 descriptors/InterfaceGroup#interfaces., |
| 272 | }) |
| 273 | } |
| 274 | } |
| 275 | |
| 276 | descriptor_fieldsrust-analyzer cargo nusb 0.1.13 descriptors/descriptor_fields!! { |
| 277 | impl<'a> Configurationrust-analyzer cargo nusb 0.1.13 descriptors/Configuration#<'a> { |
| 278 | /// `bNumInterfaces` descriptor field: Number of interfaces. |
| 279 | #[doc(alias = "bNumInterfaces")] |
| 280 | pub fn num_interfacesrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Configuration<'a>`]num_interfaces(). at 4 -> u8; |
| 281 | |
| 282 | /// `bConfigurationValue` descriptor field: Identifier for the configuration. |
| 283 | /// |
| 284 | /// Pass this value to |
| 285 | /// [`Device::set_configuration`][crate::Device::set_configuration] to |
| 286 | /// select this configuration. |
| 287 | #[doc(alias = "bConfigurationValue")] |
| 288 | pub fn configuration_valuerust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Configuration<'a>`]configuration_value(). at 5 -> u8; |
| 289 | |
| 290 | fn string_index_rawrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Configuration<'a>`]string_index_raw(). at 6 -> u8; |
| 291 | |
| 292 | /// `bmAttributes` descriptor field: Bitmap of configuration attributes. |
| 293 | #[doc(alias = "bmAttributes")] |
| 294 | pub fn attributesrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Configuration<'a>`]attributes(). at 7 -> u8; |
| 295 | |
| 296 | /// `bMaxPower` descriptor field: Maximum power, in units of **2** milliamps. |
| 297 | #[doc(alias = "bMaxPower")] |
| 298 | pub fn max_powerrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Configuration<'a>`]max_power(). at 8 -> u8; |
| 299 | } |
| 300 | } |
| 301 | |
| 302 | impl<'a> Configurationrust-analyzer cargo nusb 0.1.13 descriptors/Configuration#<'a> { |
| 303 | /// Index of the string descriptor describing this configuration. |
| 304 | #[doc(alias = "iConfiguration")] |
| 305 | pub fn string_indexrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Configuration<'a>`]string_index().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<u8> { |
| 306 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(self.string_index_rawrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Configuration<'a>`]string_index_raw().()).filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]filter().(|&i| i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().0) |
| 307 | } |
| 308 | } |
| 309 | |
| 310 | struct DebugEntriesrust-analyzer cargo nusb 0.1.13 descriptors/DebugEntries#<F>(F); |
| 311 | |
| 312 | impl<F, I> Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# for DebugEntriesrust-analyzer cargo nusb 0.1.13 descriptors/DebugEntries#<F> |
| 313 | where |
| 314 | F: Fnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/Fn#() -> I, |
| 315 | I: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#, |
| 316 | I::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#: Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug#, |
| 317 | { |
| 318 | fn fmtrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`DebugEntries<F>`][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# { |
| 319 | f.debug_listrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]debug_list().().entriesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugList<'a, 'b>`]entries().(self.0rust-analyzer cargo nusb 0.1.13 descriptors/DebugEntries#0.()).finishrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugList<'a, 'b>`]finish().() |
| 320 | } |
| 321 | } |
| 322 | |
| 323 | impl<'a> Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# for Configurationrust-analyzer cargo nusb 0.1.13 descriptors/Configuration#<'a> { |
| 324 | fn fmtrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Configuration<'a>`][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# { |
| 325 | f.debug_structrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]debug_struct().("Configuration") |
| 326 | .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("configuration_value", &self.configuration_valuerust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Configuration<'a>`]configuration_value().()) |
| 327 | .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("num_interfaces", &self.num_interfacesrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Configuration<'a>`]num_interfaces().()) |
| 328 | .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("attributes", &self.attributesrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Configuration<'a>`]attributes().()) |
| 329 | .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("max_power", &self.max_powerrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Configuration<'a>`]max_power().()) |
| 330 | .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("string_index", &self.string_indexrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Configuration<'a>`]string_index().()) |
| 331 | .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().( |
| 332 | "interface_alt_settings", |
| 333 | &DebugEntriesrust-analyzer cargo nusb 0.1.13 descriptors/DebugEntries#(|| self.interface_alt_settingsrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Configuration<'a>`]interface_alt_settings().()), |
| 334 | ) |
| 335 | .finishrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]finish().() |
| 336 | } |
| 337 | } |
| 338 | |
| 339 | /// Interface descriptors for alternate settings, grouped by the interface number. |
| 340 | #[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:)] |
| 341 | pub struct InterfaceGrouprust-analyzer cargo nusb 0.1.13 descriptors/InterfaceGroup#<'a> { |
| 342 | intf_numberrust-analyzer cargo nusb 0.1.13 descriptors/InterfaceGroup#intf_number.: u8, |
| 343 | interfacesrust-analyzer cargo nusb 0.1.13 descriptors/InterfaceGroup#interfaces.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<InterfaceAltSettingrust-analyzer cargo nusb 0.1.13 descriptors/InterfaceAltSetting#<'a>>, |
| 344 | } |
| 345 | |
| 346 | impl<'a> InterfaceGrouprust-analyzer cargo nusb 0.1.13 descriptors/InterfaceGroup#<'a> { |
| 347 | /// `bInterfaceNumber` descriptor field: Identifier for the interface. |
| 348 | /// |
| 349 | /// Pass this to [`Device::claim_interface`][crate::Device::claim_interface] to work with the interface. |
| 350 | #[doc(alias = "bInterfaceNumber")] |
| 351 | pub fn interface_numberrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceGroup<'a>`]interface_number().(&self) -> u8 { |
| 352 | self.intf_numberrust-analyzer cargo nusb 0.1.13 descriptors/InterfaceGroup#intf_number. |
| 353 | } |
| 354 | |
| 355 | /// Iterator over alternate settings of the interface. |
| 356 | pub fn alt_settingsrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceGroup<'a>`]alt_settings().(&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# = InterfaceAltSettingrust-analyzer cargo nusb 0.1.13 descriptors/InterfaceAltSetting#> { |
| 357 | self.interfacesrust-analyzer cargo nusb 0.1.13 descriptors/InterfaceGroup#interfaces..iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().() |
| 358 | } |
| 359 | } |
| 360 | |
| 361 | /// Information about a USB interface alternate setting, with access to associated endpoints and other descriptors. |
| 362 | /// |
| 363 | /// An interface descriptor represents a single alternate setting of |
| 364 | /// an interface. Multiple interface descriptors with the same [`interface_number`][Self::interface_number] |
| 365 | /// but different [`alternate_setting`][Self::alternate_setting] values represent different alternate settings. |
| 366 | #[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:)] |
| 367 | pub struct InterfaceAltSettingrust-analyzer cargo nusb 0.1.13 descriptors/InterfaceAltSetting#<'a>(&'a [u8]); |
| 368 | |
| 369 | impl<'a> InterfaceAltSettingrust-analyzer cargo nusb 0.1.13 descriptors/InterfaceAltSetting#<'a> { |
| 370 | /// Get the interface descriptor followed by all trailing endpoint and other |
| 371 | /// descriptors up to the next interface descriptor. |
| 372 | pub fn descriptorsrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]descriptors().(&self) -> Descriptorsrust-analyzer cargo nusb 0.1.13 descriptors/Descriptors# { |
| 373 | Descriptorsrust-analyzer cargo nusb 0.1.13 descriptors/Descriptors#(self.0rust-analyzer cargo nusb 0.1.13 descriptors/InterfaceAltSetting#0.) |
| 374 | } |
| 375 | |
| 376 | /// Get the endpoints of this interface. |
| 377 | pub fn endpointsrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]endpoints().(&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# = Endpointrust-analyzer cargo nusb 0.1.13 descriptors/Endpoint#> { |
| 378 | self.descriptorsrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]descriptors().() |
| 379 | .split_by_typerust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Descriptors<'a>`]split_by_type().(DESCRIPTOR_TYPE_ENDPOINTrust-analyzer cargo nusb 0.1.13 descriptors/DESCRIPTOR_TYPE_ENDPOINT., DESCRIPTOR_LEN_ENDPOINTrust-analyzer cargo nusb 0.1.13 descriptors/DESCRIPTOR_LEN_ENDPOINT.) |
| 380 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(Endpointrust-analyzer cargo nusb 0.1.13 descriptors/Endpoint#) |
| 381 | } |
| 382 | } |
| 383 | |
| 384 | descriptor_fieldsrust-analyzer cargo nusb 0.1.13 descriptors/descriptor_fields!! { |
| 385 | impl<'a> InterfaceAltSettingrust-analyzer cargo nusb 0.1.13 descriptors/InterfaceAltSetting#<'a> { |
| 386 | /// `bInterfaceNumber` descriptor field: Identifier for the interface. |
| 387 | /// |
| 388 | /// Pass this to [`Device::claim_interface`][crate::Device::claim_interface] to work with the interface. |
| 389 | #[doc(alias="bInterfaceNumber")] |
| 390 | pub fn interface_numberrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]interface_number(). at 2 -> u8; |
| 391 | |
| 392 | /// `bAlternateSetting` descriptor field: Identifier for this alternate setting. |
| 393 | /// |
| 394 | /// Pass this to [`Interface::set_alt_setting`][crate::Interface::set_alt_setting] to use this alternate setting. |
| 395 | #[doc(alias="bAlternateSetting")] |
| 396 | pub fn alternate_settingrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]alternate_setting(). at 3 -> u8; |
| 397 | |
| 398 | /// `bNumEndpoints` descriptor field: Number of endpoints in this alternate setting. |
| 399 | #[doc(alias="bNumEndpoints")] |
| 400 | pub fn num_endpointsrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]num_endpoints(). at 4 -> u8; |
| 401 | |
| 402 | /// `bInterfaceClass` descriptor field: Standard interface class. |
| 403 | #[doc(alias="bInterfaceClass")] |
| 404 | pub fn classrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]class(). at 5 -> u8; |
| 405 | |
| 406 | /// `bInterfaceSubClass` descriptor field: Standard interface subclass. |
| 407 | #[doc(alias="bInterfaceSubClass")] |
| 408 | pub fn subclassrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]subclass(). at 6 -> u8; |
| 409 | |
| 410 | /// `bInterfaceProtocol` descriptor field: Standard interface protocol. |
| 411 | #[doc(alias="bInterfaceProtocol")] |
| 412 | pub fn protocolrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]protocol(). at 7 -> u8; |
| 413 | |
| 414 | fn string_index_rawrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]string_index_raw(). at 8 -> u8; |
| 415 | } |
| 416 | } |
| 417 | |
| 418 | impl<'a> InterfaceAltSettingrust-analyzer cargo nusb 0.1.13 descriptors/InterfaceAltSetting#<'a> { |
| 419 | /// Index of the string descriptor describing this interface or alternate setting. |
| 420 | #[doc(alias = "iInterface")] |
| 421 | pub fn string_indexrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]string_index().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<u8> { |
| 422 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(self.string_index_rawrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]string_index_raw().()).filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]filter().(|&i| i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().0) |
| 423 | } |
| 424 | } |
| 425 | |
| 426 | impl<'a> Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# for InterfaceAltSettingrust-analyzer cargo nusb 0.1.13 descriptors/InterfaceAltSetting#<'a> { |
| 427 | fn fmtrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`][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# { |
| 428 | f.debug_structrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]debug_struct().("InterfaceAltSetting") |
| 429 | .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 descriptors/impl#[`InterfaceAltSetting<'a>`]interface_number().()) |
| 430 | .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("alternate_setting", &self.alternate_settingrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]alternate_setting().()) |
| 431 | .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("num_endpoints", &self.num_endpointsrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]num_endpoints().()) |
| 432 | .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("class", &self.classrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]class().()) |
| 433 | .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("subclass", &self.subclassrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]subclass().()) |
| 434 | .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("protocol", &self.protocolrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]protocol().()) |
| 435 | .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("string_index", &self.string_indexrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]string_index().()) |
| 436 | .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("endpoints", &DebugEntriesrust-analyzer cargo nusb 0.1.13 descriptors/DebugEntries#(|| self.endpointsrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]endpoints().())) |
| 437 | .finishrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]finish().() |
| 438 | } |
| 439 | } |
| 440 | |
| 441 | /// Information about a USB endpoint, with access to any associated descriptors. |
| 442 | pub struct Endpointrust-analyzer cargo nusb 0.1.13 descriptors/Endpoint#<'a>(&'a [u8]); |
| 443 | |
| 444 | impl<'a> Endpointrust-analyzer cargo nusb 0.1.13 descriptors/Endpoint#<'a> { |
| 445 | /// Get the endpoint descriptor followed by all trailing descriptors up to the next endpoint or interface descriptor. |
| 446 | pub fn descriptorsrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Endpoint<'a>`]descriptors().(&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# = Descriptorrust-analyzer cargo nusb 0.1.13 descriptors/Descriptor#> { |
| 447 | Descriptorsrust-analyzer cargo nusb 0.1.13 descriptors/Descriptors#(self.0rust-analyzer cargo nusb 0.1.13 descriptors/Endpoint#0.) |
| 448 | } |
| 449 | |
| 450 | /// Get the endpoint's direction. |
| 451 | pub fn directionrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Endpoint<'a>`]direction().(&self) -> Directionrust-analyzer cargo nusb 0.1.13 transfer/control/Direction# { |
| 452 | match self.addressrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Endpoint<'a>`]address().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitAnd<Self>`]bitand().0x80 { |
| 453 | 0 => Directionrust-analyzer cargo nusb 0.1.13 transfer/control/Direction#::Outrust-analyzer cargo nusb 0.1.13 transfer/control/Direction#Out#, |
| 454 | _ => Directionrust-analyzer cargo nusb 0.1.13 transfer/control/Direction#::Inrust-analyzer cargo nusb 0.1.13 transfer/control/Direction#In#, |
| 455 | } |
| 456 | } |
| 457 | |
| 458 | /// Get the endpoint's transfer type. |
| 459 | pub fn transfer_typerust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Endpoint<'a>`]transfer_type().(&self) -> EndpointTyperust-analyzer cargo nusb 0.1.13 transfer/EndpointType# { |
| 460 | match self.attributesrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Endpoint<'a>`]attributes().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitAnd<Self>`]bitand().0x03 { |
| 461 | 0 => EndpointTyperust-analyzer cargo nusb 0.1.13 transfer/EndpointType#::Controlrust-analyzer cargo nusb 0.1.13 transfer/EndpointType#Control#, |
| 462 | 1 => EndpointTyperust-analyzer cargo nusb 0.1.13 transfer/EndpointType#::Isochronousrust-analyzer cargo nusb 0.1.13 transfer/EndpointType#Isochronous#, |
| 463 | 2 => EndpointTyperust-analyzer cargo nusb 0.1.13 transfer/EndpointType#::Bulkrust-analyzer cargo nusb 0.1.13 transfer/EndpointType#Bulk#, |
| 464 | 3 => EndpointTyperust-analyzer cargo nusb 0.1.13 transfer/EndpointType#::Interruptrust-analyzer cargo nusb 0.1.13 transfer/EndpointType#Interrupt#, |
| 465 | _ => unreachablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/unreachable!!(), |
| 466 | } |
| 467 | } |
| 468 | |
| 469 | /// Get the maximum packet size in bytes. |
| 470 | pub fn max_packet_sizerust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Endpoint<'a>`]max_packet_size().(&self) -> usize { |
| 471 | (self.max_packet_size_rawrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Endpoint<'a>`]max_packet_size_raw().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u16][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u16][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u16][`BitAnd<Self>`]bitand().((1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u16][`Shl<i32>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u16][`Shl<i32>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u16][`Shl<i32>`]shl().11) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Sub<Self>`]sub().1)) as usize |
| 472 | } |
| 473 | |
| 474 | /// For isochronous endpoints at high speed, get the number of packets per microframe (1, 2, or 3). |
| 475 | pub fn packets_per_microframerust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Endpoint<'a>`]packets_per_microframe().(&self) -> u8 { |
| 476 | ((self.max_packet_size_rawrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Endpoint<'a>`]max_packet_size_raw().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u16][`Shr<i32>`]shr().>>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u16][`Shr<i32>`]shr(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u16][`Shr<i32>`]shr().11) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u16][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u16][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u16][`BitAnd<Self>`]bitand().0b11) as u8 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Add<Self>`]add().1 |
| 477 | } |
| 478 | } |
| 479 | |
| 480 | descriptor_fieldsrust-analyzer cargo nusb 0.1.13 descriptors/descriptor_fields!! { |
| 481 | impl<'a> Endpointrust-analyzer cargo nusb 0.1.13 descriptors/Endpoint#<'a> { |
| 482 | /// Get the `bEndpointAddress` descriptor field: Endpoint address. |
| 483 | #[doc(alias = "bEndpointAddress")] |
| 484 | pub fn addressrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Endpoint<'a>`]address(). at 2 -> u8; |
| 485 | |
| 486 | /// Get the raw value of the `bmAttributes` descriptor field. |
| 487 | /// |
| 488 | /// See [`transfer_type``][Self::transfer_type] for the transfer type field. |
| 489 | #[doc(alias = "bmAttributes")] |
| 490 | pub fn attributesrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Endpoint<'a>`]attributes(). at 3 -> u8; |
| 491 | |
| 492 | /// Get the raw value of the `wMaxPacketSize` descriptor field. |
| 493 | /// |
| 494 | /// See [`max_macket_size`][Self::max_packet_size] and [`packets_per_microframe`][Self::packets_per_microframe] |
| 495 | /// for the parsed subfields. |
| 496 | #[doc(alias = "wMaxPacketSize")] |
| 497 | pub fn max_packet_size_rawrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Endpoint<'a>`]max_packet_size_raw(). at 4 -> u16; |
| 498 | |
| 499 | /// Get the `bInterval` field: Polling interval in frames or microframes. |
| 500 | #[doc(alias = "bInterval")] |
| 501 | pub fn intervalrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Endpoint<'a>`]interval(). at 6 -> u8; |
| 502 | } |
| 503 | } |
| 504 | |
| 505 | impl<'a> Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# for Endpointrust-analyzer cargo nusb 0.1.13 descriptors/Endpoint#<'a> { |
| 506 | fn fmtrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Endpoint<'a>`][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# { |
| 507 | f.debug_structrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]debug_struct().("Endpoint") |
| 508 | .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("address", &format_argsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/format_args!!("0x{:02X}", self.addressrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Endpoint<'a>`]address().())) |
| 509 | .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("direction", &self.directionrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Endpoint<'a>`]direction().()) |
| 510 | .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("transfer_type", &self.transfer_typerust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Endpoint<'a>`]transfer_type().()) |
| 511 | .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("max_packet_size", &self.max_packet_sizerust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Endpoint<'a>`]max_packet_size().()) |
| 512 | .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("packets_per_microframe", &self.packets_per_microframerust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Endpoint<'a>`]packets_per_microframe().()) |
| 513 | .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("interval", &self.intervalrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Endpoint<'a>`]interval().()) |
| 514 | .finishrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]finish().() |
| 515 | } |
| 516 | } |
| 517 | |
| 518 | /// Error from [`crate::Device::active_configuration`] |
| 519 | #[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:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, 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:)] |
| 520 | pub struct ActiveConfigurationErrorrust-analyzer cargo nusb 0.1.13 descriptors/ActiveConfigurationError# { |
| 521 | pub(craterust-analyzer cargo nusb 0.1.13 crate/) configuration_valuerust-analyzer cargo nusb 0.1.13 descriptors/ActiveConfigurationError#configuration_value.: u8, |
| 522 | } |
| 523 | |
| 524 | impl Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for ActiveConfigurationErrorrust-analyzer cargo nusb 0.1.13 descriptors/ActiveConfigurationError# { |
| 525 | fn fmtrust-analyzer cargo nusb 0.1.13 descriptors/impl#[ActiveConfigurationError][Display]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# { |
| 526 | if self.configuration_valuerust-analyzer cargo nusb 0.1.13 descriptors/ActiveConfigurationError#configuration_value. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().0 { |
| 527 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "device is not configured") |
| 528 | } else { |
| 529 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!( |
| 530 | f, |
| 531 | "no descriptor found for active configuration {}", |
| 532 | self.configuration_valuerust-analyzer cargo nusb 0.1.13 descriptors/ActiveConfigurationError#configuration_value. |
| 533 | ) |
| 534 | } |
| 535 | } |
| 536 | } |
| 537 | |
| 538 | impl stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std error/::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# for ActiveConfigurationErrorrust-analyzer cargo nusb 0.1.13 descriptors/ActiveConfigurationError# {} |
| 539 | |
| 540 | impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<ActiveConfigurationErrorrust-analyzer cargo nusb 0.1.13 descriptors/ActiveConfigurationError#> for Errorrust-analyzer cargo nusb 0.1.13 Error# { |
| 541 | fn fromrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`std::io::Error`][`From<ActiveConfigurationError>`]from().(value: ActiveConfigurationErrorrust-analyzer cargo nusb 0.1.13 descriptors/ActiveConfigurationError#) -> Selfrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`std::io::Error`][`From<ActiveConfigurationError>`] { |
| 542 | Errorrust-analyzer cargo nusb 0.1.13 Error#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]new().(ErrorKindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#::Otherrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#Other#, value) |
| 543 | } |
| 544 | } |
| 545 | |
| 546 | /// Split a chain of concatenated configuration descriptors by `wTotalLength` |
| 547 | pub(craterust-analyzer cargo nusb 0.1.13 crate/) fn parse_concatenated_config_descriptorsrust-analyzer cargo nusb 0.1.13 descriptors/parse_concatenated_config_descriptors().(mut buf: &[u8]) -> 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# = &[u8]> { |
| 548 | iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::from_fnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/sources/from_fn/from_fn().(move || { |
| 549 | let total_len = validate_config_descriptorrust-analyzer cargo nusb 0.1.13 descriptors/validate_config_descriptor().(buf)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch().; |
| 550 | let descriptors = &buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#total_len]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().; |
| 551 | buf = &buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().total_len..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().; |
| 552 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(descriptors) |
| 553 | }) |
| 554 | } |
| 555 | |
| 556 | pub(craterust-analyzer cargo nusb 0.1.13 crate/) fn validate_string_descriptorrust-analyzer cargo nusb 0.1.13 descriptors/validate_string_descriptor().(data: &[u8]) -> bool { |
| 557 | data.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().2 && data[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). as usize rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().data.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() && data[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().DESCRIPTOR_TYPE_STRINGrust-analyzer cargo nusb 0.1.13 descriptors/DESCRIPTOR_TYPE_STRING. |
| 558 | } |
| 559 | |
| 560 | pub(craterust-analyzer cargo nusb 0.1.13 crate/) fn decode_string_descriptorrust-analyzer cargo nusb 0.1.13 descriptors/decode_string_descriptor().(data: &[u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, ()> { |
| 561 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().validate_string_descriptorrust-analyzer cargo nusb 0.1.13 descriptors/validate_string_descriptor().(data) { |
| 562 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(()); |
| 563 | } |
| 564 | |
| 565 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(char::decode_utf16rust-analyzer cargo core https://github.com/rust-lang/rust/library/core char/methods/impl#[char]decode_utf16().( |
| 566 | data[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().2..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). |
| 567 | .chunks_exactrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact().(2) |
| 568 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|c| u16::from_le_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u16]from_le_bytes().(c.try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryInto#try_into().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().())), |
| 569 | ) |
| 570 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|r| r.unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_or().(char::REPLACEMENT_CHARACTERrust-analyzer cargo core https://github.com/rust-lang/rust/library/core char/methods/impl#[char]REPLACEMENT_CHARACTER.)) |
| 571 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>()) |
| 572 | } |
| 573 | |
| 574 | /// Make public when fuzzing |
| 575 | #[cfg(fuzzing)] |
| 576 | pub fn fuzz_parse_concatenated_config_descriptors(buf: &[u8]) -> 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# = &[u8]> { |
| 577 | parse_concatenated_config_descriptorsrust-analyzer cargo nusb 0.1.13 descriptors/parse_concatenated_config_descriptors().(buf) |
| 578 | } |
| 579 | |
| 580 | #[cfg(test)] |
| 581 | mod test_concatenatedrust-analyzer cargo nusb 0.1.13 descriptors/test_concatenated/ { |
| 582 | use superrust-analyzer cargo nusb 0.1.13 descriptors/::parse_concatenated_config_descriptorsrust-analyzer cargo nusb 0.1.13 descriptors/parse_concatenated_config_descriptors().; |
| 583 | |
| 584 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 585 | fn test_emptyrust-analyzer cargo nusb 0.1.13 descriptors/test_concatenated/test_empty().() { |
| 586 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 587 | parse_concatenated_config_descriptorsrust-analyzer cargo nusb 0.1.13 descriptors/parse_concatenated_config_descriptors().(&[]).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<&[u8]>>(), |
| 588 | Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::<&[u8]>::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().() |
| 589 | ); |
| 590 | } |
| 591 | |
| 592 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 593 | fn test_shortrust-analyzer cargo nusb 0.1.13 descriptors/test_concatenated/test_short().() { |
| 594 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 595 | parse_concatenated_config_descriptorsrust-analyzer cargo nusb 0.1.13 descriptors/parse_concatenated_config_descriptors().(&[0]).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<&[u8]>>(), |
| 596 | Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::<&[u8]>::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().() |
| 597 | ); |
| 598 | } |
| 599 | |
| 600 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 601 | fn test_invalid_total_lenrust-analyzer cargo nusb 0.1.13 descriptors/test_concatenated/test_invalid_total_len().() { |
| 602 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 603 | parse_concatenated_config_descriptorsrust-analyzer cargo nusb 0.1.13 descriptors/parse_concatenated_config_descriptors().(&[9, 2, 0, 0, 0, 0, 0, 0, 0]) |
| 604 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<&[u8]>>(), |
| 605 | Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::<&[u8]>::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().() |
| 606 | ); |
| 607 | } |
| 608 | |
| 609 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 610 | fn test_one_configrust-analyzer cargo nusb 0.1.13 descriptors/test_concatenated/test_one_config().() { |
| 611 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 612 | parse_concatenated_config_descriptorsrust-analyzer cargo nusb 0.1.13 descriptors/parse_concatenated_config_descriptors().(&[9, 2, 9, 0, 0, 0, 0, 0, 0]) |
| 613 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<&[u8]>>(), |
| 614 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![&[9, 2, 9, 0, 0, 0, 0, 0, 0]] |
| 615 | ); |
| 616 | |
| 617 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 618 | parse_concatenated_config_descriptorsrust-analyzer cargo nusb 0.1.13 descriptors/parse_concatenated_config_descriptors().(&[9, 2, 13, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0]) |
| 619 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<&[u8]>>(), |
| 620 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![&[9, 2, 13, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0]] |
| 621 | ); |
| 622 | } |
| 623 | |
| 624 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 625 | fn test_two_configsrust-analyzer cargo nusb 0.1.13 descriptors/test_concatenated/test_two_configs().() { |
| 626 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 627 | parse_concatenated_config_descriptorsrust-analyzer cargo nusb 0.1.13 descriptors/parse_concatenated_config_descriptors().(&[ |
| 628 | 9, 2, 13, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 9, 2, 9, 0, 0, 0, 0, 0, 0 |
| 629 | ]) |
| 630 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<&[u8]>>(), |
| 631 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 632 | [9, 2, 13, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0].as_slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`]as_slice().(), |
| 633 | [9, 2, 9, 0, 0, 0, 0, 0, 0].as_slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`]as_slice().() |
| 634 | ] |
| 635 | ); |
| 636 | } |
| 637 | } |
| 638 | |
| 639 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 640 | fn test_empty_configrust-analyzer cargo nusb 0.1.13 descriptors/test_empty_config().() { |
| 641 | let c = Configurationrust-analyzer cargo nusb 0.1.13 descriptors/Configuration#(&[9, 2, 9, 0, 0, 1, 0, 0, 250]); |
| 642 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(c.num_interfacesrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Configuration<'a>`]num_interfaces().(), 0); |
| 643 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(c.configuration_valuerust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Configuration<'a>`]configuration_value().(), 1); |
| 644 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(c.string_indexrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Configuration<'a>`]string_index().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 645 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(c.interfacesrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Configuration<'a>`]interfaces().().countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#count().(), 0); |
| 646 | } |
| 647 | |
| 648 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 649 | fn test_malformedrust-analyzer cargo nusb 0.1.13 descriptors/test_malformed().() { |
| 650 | let c = Configurationrust-analyzer cargo nusb 0.1.13 descriptors/Configuration#(&[9, 2, 0, 0, 0, 1, 0, 0, 2, 5, 250, 0, 0, 0]); |
| 651 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(c.interfacesrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Configuration<'a>`]interfaces().().nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/map/impl#[`Map<I, F>`][Iterator]next().().is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().()); |
| 652 | } |
| 653 | |
| 654 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 655 | #[rustfmt::skip] |
| 656 | fn test_linux_root_hubrust-analyzer cargo nusb 0.1.13 descriptors/test_linux_root_hub().() { |
| 657 | let c = Configurationrust-analyzer cargo nusb 0.1.13 descriptors/Configuration#(&[ |
| 658 | 0x09, 0x02, 0x19, 0x00, 0x01, 0x01, 0x00, 0xe0, 0x00, |
| 659 | 0x09, 0x04, 0x00, 0x00, 0x01, 0x09, 0x00, 0x00, 0x00, |
| 660 | 0x07, 0x05, 0x81, 0x03, 0x04, 0x00, 0x0c |
| 661 | ]); |
| 662 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(c.num_interfacesrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Configuration<'a>`]num_interfaces().(), 1); |
| 663 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(c.configuration_valuerust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Configuration<'a>`]configuration_value().(), 1); |
| 664 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(c.max_powerrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Configuration<'a>`]max_power().(), 0); |
| 665 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(c.interfacesrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Configuration<'a>`]interfaces().().countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#count().(), 1); |
| 666 | |
| 667 | let interface = c.interfacesrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Configuration<'a>`]interfaces().().nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/map/impl#[`Map<I, F>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 668 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(interface.interface_numberrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceGroup<'a>`]interface_number().(), 0); |
| 669 | |
| 670 | let mut alts = interface.alt_settingsrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceGroup<'a>`]alt_settings().(); |
| 671 | |
| 672 | let alt = alts.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/cloned/impl#[`Cloned<I>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 673 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(alt.interface_numberrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]interface_number().(), 0); |
| 674 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(alt.alternate_settingrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]alternate_setting().(), 0); |
| 675 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(alt.num_endpointsrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]num_endpoints().(), 1); |
| 676 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(alt.classrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]class().(), 9); |
| 677 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(alt.subclassrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]subclass().(), 0); |
| 678 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(alt.protocolrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]protocol().(), 0); |
| 679 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(alt.endpointsrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]endpoints().().countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#count().(), 1); |
| 680 | |
| 681 | let endpoint = alt.endpointsrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]endpoints().().nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/map/impl#[`Map<I, F>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 682 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(endpoint.addressrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Endpoint<'a>`]address().(), 0x81); |
| 683 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(endpoint.transfer_typerust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Endpoint<'a>`]transfer_type().(), EndpointTyperust-analyzer cargo nusb 0.1.13 transfer/EndpointType#::Interruptrust-analyzer cargo nusb 0.1.13 transfer/EndpointType#Interrupt#); |
| 684 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(endpoint.max_packet_sizerust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Endpoint<'a>`]max_packet_size().(), 4); |
| 685 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(endpoint.intervalrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Endpoint<'a>`]interval().(), 12); |
| 686 | |
| 687 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(alts.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/cloned/impl#[`Cloned<I>`][Iterator]next().().is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().()); |
| 688 | } |
| 689 | |
| 690 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 691 | #[rustfmt::skip] |
| 692 | fn test_dell_webcamrust-analyzer cargo nusb 0.1.13 descriptors/test_dell_webcam().() { |
| 693 | let c = Configurationrust-analyzer cargo nusb 0.1.13 descriptors/Configuration#(&[ |
| 694 | 0x09, 0x02, 0xa3, 0x02, 0x02, 0x01, 0x00, 0x80, 0xfa, |
| 695 | |
| 696 | // unknown (skipped) |
| 697 | 0x28, 0xff, 0x42, 0x49, 0x53, 0x54, 0x00, 0x01, 0x06, 0x01, 0x10, 0x00, |
| 698 | 0x00, 0x00, 0x00, 0x00, 0xd1, 0x10, 0xd0, 0x07, 0xd2, 0x11, 0xf4, 0x01, |
| 699 | 0xd3, 0x12, 0xf4, 0x01, 0xd4, 0x13, 0xf4, 0x01, 0xd5, 0x14, 0xd0, 0x07, |
| 700 | 0xd6, 0x15, 0xf4, 0x01, |
| 701 | |
| 702 | // interface association |
| 703 | 0x08, 0x0b, 0x00, 0x02, 0x0e, 0x03, 0x00, 0x05, |
| 704 | |
| 705 | // interface |
| 706 | 0x09, 0x04, 0x00, 0x00, 0x01, 0x0e, 0x01, 0x00, 0x05, |
| 707 | |
| 708 | // VideoControl |
| 709 | 0x0d, 0x24, 0x01, 0x00, 0x01, 0x67, 0x00, 0xc0, 0xe1, 0xe4, 0x00, 0x01, 0x01, |
| 710 | |
| 711 | // VideoControl |
| 712 | 0x09, 0x24, 0x03, 0x05, 0x01, 0x01, 0x00, 0x04, 0x00, |
| 713 | |
| 714 | // VideoControl |
| 715 | 0x1a, 0x24, 0x06, 0x03, 0x70, 0x33, 0xf0, 0x28, 0x11, 0x63, 0x2e, 0x4a, |
| 716 | 0xba, 0x2c, 0x68, 0x90, 0xeb, 0x33, 0x40, 0x16, 0x08, 0x01, 0x02, 0x01, |
| 717 | 0x9f, 0x00, |
| 718 | |
| 719 | // VideoControl |
| 720 | 0x1a, 0x24, 0x06, 0x04, 0xc3, 0x85, 0xb8, 0x0f, 0xc2, 0x68, 0x47, 0x45, |
| 721 | 0x90, 0xf7, 0x8f, 0x47, 0x57, 0x9d, 0x95, 0xfc, 0x08, 0x01, 0x03, 0x01, |
| 722 | 0x0f, 0x00, |
| 723 | |
| 724 | // VideoControl |
| 725 | 0x12, 0x24, 0x02, 0x01, 0x01, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 726 | 0x00, 0x00, 0x03, 0x0e, 0x00, 0x20, |
| 727 | |
| 728 | // VideoControl |
| 729 | 0x0b, 0x24, 0x05, 0x02, 0x01, 0x00, 0x00, 0x02, 0x7f, 0x17, 0x00, |
| 730 | |
| 731 | // Endpoint |
| 732 | 0x07, 0x05, 0x83, 0x03, 0x10, 0x00, 0x06, |
| 733 | |
| 734 | // Class-specific endpoint info |
| 735 | 0x05, 0x25, 0x03, 0x80, 0x00, |
| 736 | |
| 737 | // Interface |
| 738 | 0x09, 0x04, 0x01, 0x00, 0x00, 0x0e, 0x02, 0x00, 0x00, |
| 739 | |
| 740 | // Video Streaming |
| 741 | 0x0f, 0x24, 0x01, 0x02, 0x85, 0x01, 0x81, 0x00, 0x05, 0x00, 0x00, 0x00, |
| 742 | 0x01, 0x00, 0x00, |
| 743 | |
| 744 | // Video streaming |
| 745 | 0x0b, 0x24, 0x06, 0x01, 0x05, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, |
| 746 | |
| 747 | // Video streaming (12 more omitted) |
| 748 | 0x06, 0x24, 0x0d, 0x01, 0x01, 0x04, |
| 749 | |
| 750 | // Interface |
| 751 | 0x09, 0x04, 0x01, 0x01, 0x01, 0x0e, 0x02, 0x00, 0x00, |
| 752 | |
| 753 | // Endpoint |
| 754 | 0x07, 0x05, 0x81, 0x05, 0x80, 0x00, 0x01, |
| 755 | |
| 756 | // Interface |
| 757 | 0x09, 0x04, 0x01, 0x02, 0x01, 0x0e, 0x02, 0x00, 0x00, |
| 758 | |
| 759 | // Endpoint |
| 760 | 0x07, 0x05, 0x81, 0x05, 0x00, 0x01, 0x01, |
| 761 | |
| 762 | // Interface |
| 763 | 0x09, 0x04, 0x01, 0x03, 0x01, 0x0e, 0x02, 0x00, 0x00, |
| 764 | |
| 765 | // Endpoint |
| 766 | 0x07, 0x05, 0x81, 0x05, 0x20, 0x03, 0x01, |
| 767 | |
| 768 | // Interface |
| 769 | 0x09, 0x04, 0x01, 0x04, 0x01, 0x0e, 0x02, 0x00, 0x00, |
| 770 | |
| 771 | // Endpoint |
| 772 | 0x07, 0x05, 0x81, 0x05, 0x20, 0x0b, 0x01, |
| 773 | |
| 774 | // Interface |
| 775 | 0x09, 0x04, 0x01, 0x05, 0x01, 0x0e, 0x02, 0x00, 0x00, |
| 776 | |
| 777 | // Endpoint |
| 778 | 0x07, 0x05, 0x81, 0x05, 0x20, 0x13, 0x01, |
| 779 | |
| 780 | // Interface |
| 781 | 0x09, 0x04, 0x01, 0x06, 0x01, 0x0e, 0x02, 0x00, 0x00, |
| 782 | |
| 783 | // Endpoint |
| 784 | 0x07, 0x05, 0x81, 0x05, 0x00, 0x14, 0x01 |
| 785 | ]); |
| 786 | |
| 787 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(c.configuration_valuerust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Configuration<'a>`]configuration_value().(), 1); |
| 788 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(c.num_interfacesrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Configuration<'a>`]num_interfaces().(), 2); |
| 789 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(c.max_powerrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Configuration<'a>`]max_power().(), 250); |
| 790 | |
| 791 | let mut interfaces = c.interfacesrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Configuration<'a>`]interfaces().(); |
| 792 | let interface = interfaces.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/map/impl#[`Map<I, F>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 793 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(interface.interface_numberrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceGroup<'a>`]interface_number().(), 0); |
| 794 | let mut alts = interface.alt_settingsrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceGroup<'a>`]alt_settings().(); |
| 795 | |
| 796 | let alt = alts.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/cloned/impl#[`Cloned<I>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 797 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(alt.interface_numberrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]interface_number().(), 0); |
| 798 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(alt.alternate_settingrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]alternate_setting().(), 0); |
| 799 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(alt.num_endpointsrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]num_endpoints().(), 1); |
| 800 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(alt.classrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]class().(), 14); |
| 801 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(alt.subclassrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]subclass().(), 1); |
| 802 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(alt.protocolrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]protocol().(), 0); |
| 803 | |
| 804 | let mut descriptors = alt.descriptorsrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]descriptors().(); |
| 805 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(descriptors.nextrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Descriptors<'a>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().descriptor_typerust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Descriptor<'a>`]descriptor_type().(), DESCRIPTOR_TYPE_INTERFACErust-analyzer cargo nusb 0.1.13 descriptors/DESCRIPTOR_TYPE_INTERFACE.); |
| 806 | for _ in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#6 { |
| 807 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(descriptors.nextrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Descriptors<'a>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().descriptor_typerust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Descriptor<'a>`]descriptor_type().(), 0x24); |
| 808 | } |
| 809 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(descriptors.nextrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Descriptors<'a>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().descriptor_typerust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Descriptor<'a>`]descriptor_type().(), DESCRIPTOR_TYPE_ENDPOINTrust-analyzer cargo nusb 0.1.13 descriptors/DESCRIPTOR_TYPE_ENDPOINT.); |
| 810 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(descriptors.nextrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Descriptors<'a>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().descriptor_typerust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Descriptor<'a>`]descriptor_type().(), 0x25); |
| 811 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(descriptors.nextrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Descriptors<'a>`][Iterator]next().().is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().()); |
| 812 | |
| 813 | let mut endpoints = alt.endpointsrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]endpoints().(); |
| 814 | |
| 815 | let endpoint = endpoints.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/map/impl#[`Map<I, F>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 816 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(endpoint.addressrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Endpoint<'a>`]address().(), 0x83); |
| 817 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(endpoint.transfer_typerust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Endpoint<'a>`]transfer_type().(), EndpointTyperust-analyzer cargo nusb 0.1.13 transfer/EndpointType#::Interruptrust-analyzer cargo nusb 0.1.13 transfer/EndpointType#Interrupt#); |
| 818 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(endpoint.max_packet_sizerust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Endpoint<'a>`]max_packet_size().(), 16); |
| 819 | |
| 820 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(endpoint.descriptorsrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Endpoint<'a>`]descriptors().().nthrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#nth().(1).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().descriptor_typerust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Descriptor<'a>`]descriptor_type().(), 0x25); |
| 821 | |
| 822 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(endpoints.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/map/impl#[`Map<I, F>`][Iterator]next().().is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().()); |
| 823 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(alts.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/cloned/impl#[`Cloned<I>`][Iterator]next().().is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().()); |
| 824 | |
| 825 | let interface = interfaces.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/map/impl#[`Map<I, F>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 826 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(interface.interface_numberrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceGroup<'a>`]interface_number().(), 1); |
| 827 | let mut alts = interface.alt_settingsrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceGroup<'a>`]alt_settings().(); |
| 828 | |
| 829 | let alt = alts.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/cloned/impl#[`Cloned<I>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 830 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(alt.interface_numberrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]interface_number().(), 1); |
| 831 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(alt.alternate_settingrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]alternate_setting().(), 0); |
| 832 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(alt.num_endpointsrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]num_endpoints().(), 0); |
| 833 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(alt.classrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]class().(), 14); |
| 834 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(alt.subclassrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]subclass().(), 2); |
| 835 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(alt.protocolrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]protocol().(), 0); |
| 836 | let mut endpoints = alt.endpointsrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]endpoints().(); |
| 837 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(endpoints.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/map/impl#[`Map<I, F>`][Iterator]next().().is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().()); |
| 838 | |
| 839 | let alt = alts.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/cloned/impl#[`Cloned<I>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 840 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(alt.interface_numberrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]interface_number().(), 1); |
| 841 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(alt.alternate_settingrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]alternate_setting().(), 1); |
| 842 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(alt.num_endpointsrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]num_endpoints().(), 1); |
| 843 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(alt.classrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]class().(), 14); |
| 844 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(alt.subclassrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]subclass().(), 2); |
| 845 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(alt.protocolrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]protocol().(), 0); |
| 846 | let mut endpoints = alt.endpointsrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]endpoints().(); |
| 847 | |
| 848 | let endpoint = endpoints.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/map/impl#[`Map<I, F>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 849 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(endpoint.addressrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Endpoint<'a>`]address().(), 0x81); |
| 850 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(endpoint.transfer_typerust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Endpoint<'a>`]transfer_type().(), EndpointTyperust-analyzer cargo nusb 0.1.13 transfer/EndpointType#::Isochronousrust-analyzer cargo nusb 0.1.13 transfer/EndpointType#Isochronous#); |
| 851 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(endpoint.max_packet_sizerust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Endpoint<'a>`]max_packet_size().(), 128); |
| 852 | |
| 853 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(endpoints.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/map/impl#[`Map<I, F>`][Iterator]next().().is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().()); |
| 854 | |
| 855 | let alt = alts.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/cloned/impl#[`Cloned<I>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 856 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(alt.interface_numberrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]interface_number().(), 1); |
| 857 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(alt.alternate_settingrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]alternate_setting().(), 2); |
| 858 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(alt.num_endpointsrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]num_endpoints().(), 1); |
| 859 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(alt.classrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]class().(), 14); |
| 860 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(alt.subclassrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]subclass().(), 2); |
| 861 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(alt.protocolrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]protocol().(), 0); |
| 862 | let mut endpoints = alt.endpointsrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]endpoints().(); |
| 863 | |
| 864 | let endpoint = endpoints.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/map/impl#[`Map<I, F>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 865 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(endpoint.addressrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Endpoint<'a>`]address().(), 0x81); |
| 866 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(endpoint.transfer_typerust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Endpoint<'a>`]transfer_type().(), EndpointTyperust-analyzer cargo nusb 0.1.13 transfer/EndpointType#::Isochronousrust-analyzer cargo nusb 0.1.13 transfer/EndpointType#Isochronous#); |
| 867 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(endpoint.max_packet_sizerust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Endpoint<'a>`]max_packet_size().(), 256); |
| 868 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(endpoint.packets_per_microframerust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Endpoint<'a>`]packets_per_microframe().(), 1); |
| 869 | |
| 870 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(endpoints.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/map/impl#[`Map<I, F>`][Iterator]next().().is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().()); |
| 871 | |
| 872 | let alt = alts.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/cloned/impl#[`Cloned<I>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 873 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(alt.interface_numberrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]interface_number().(), 1); |
| 874 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(alt.alternate_settingrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]alternate_setting().(), 3); |
| 875 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(alt.num_endpointsrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]num_endpoints().(), 1); |
| 876 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(alt.classrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]class().(), 14); |
| 877 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(alt.subclassrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]subclass().(), 2); |
| 878 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(alt.protocolrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]protocol().(), 0); |
| 879 | let mut endpoints = alt.endpointsrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]endpoints().(); |
| 880 | |
| 881 | let endpoint = endpoints.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/map/impl#[`Map<I, F>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 882 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(endpoint.addressrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Endpoint<'a>`]address().(), 0x81); |
| 883 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(endpoint.transfer_typerust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Endpoint<'a>`]transfer_type().(), EndpointTyperust-analyzer cargo nusb 0.1.13 transfer/EndpointType#::Isochronousrust-analyzer cargo nusb 0.1.13 transfer/EndpointType#Isochronous#); |
| 884 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(endpoint.max_packet_sizerust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Endpoint<'a>`]max_packet_size().(), 800); |
| 885 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(endpoint.packets_per_microframerust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Endpoint<'a>`]packets_per_microframe().(), 1); |
| 886 | |
| 887 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(endpoints.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/map/impl#[`Map<I, F>`][Iterator]next().().is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().()); |
| 888 | |
| 889 | let alt = alts.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/cloned/impl#[`Cloned<I>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 890 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(alt.interface_numberrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]interface_number().(), 1); |
| 891 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(alt.alternate_settingrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]alternate_setting().(), 4); |
| 892 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(alt.num_endpointsrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]num_endpoints().(), 1); |
| 893 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(alt.classrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]class().(), 14); |
| 894 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(alt.subclassrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]subclass().(), 2); |
| 895 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(alt.protocolrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]protocol().(), 0); |
| 896 | let mut endpoints = alt.endpointsrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]endpoints().(); |
| 897 | |
| 898 | let endpoint = endpoints.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/map/impl#[`Map<I, F>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 899 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(endpoint.addressrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Endpoint<'a>`]address().(), 0x81); |
| 900 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(endpoint.transfer_typerust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Endpoint<'a>`]transfer_type().(), EndpointTyperust-analyzer cargo nusb 0.1.13 transfer/EndpointType#::Isochronousrust-analyzer cargo nusb 0.1.13 transfer/EndpointType#Isochronous#); |
| 901 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(endpoint.max_packet_sizerust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Endpoint<'a>`]max_packet_size().(), 800); |
| 902 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(endpoint.packets_per_microframerust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Endpoint<'a>`]packets_per_microframe().(), 2); |
| 903 | |
| 904 | let alt = alts.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/cloned/impl#[`Cloned<I>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 905 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(alt.interface_numberrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]interface_number().(), 1); |
| 906 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(alt.alternate_settingrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]alternate_setting().(), 5); |
| 907 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(alt.num_endpointsrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]num_endpoints().(), 1); |
| 908 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(alt.classrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]class().(), 14); |
| 909 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(alt.subclassrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]subclass().(), 2); |
| 910 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(alt.protocolrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]protocol().(), 0); |
| 911 | let mut endpoints = alt.endpointsrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]endpoints().(); |
| 912 | |
| 913 | let endpoint = endpoints.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/map/impl#[`Map<I, F>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 914 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(endpoint.addressrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Endpoint<'a>`]address().(), 0x81); |
| 915 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(endpoint.transfer_typerust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Endpoint<'a>`]transfer_type().(), EndpointTyperust-analyzer cargo nusb 0.1.13 transfer/EndpointType#::Isochronousrust-analyzer cargo nusb 0.1.13 transfer/EndpointType#Isochronous#); |
| 916 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(endpoint.max_packet_sizerust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Endpoint<'a>`]max_packet_size().(), 800); |
| 917 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(endpoint.packets_per_microframerust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Endpoint<'a>`]packets_per_microframe().(), 3); |
| 918 | |
| 919 | let alt = alts.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/cloned/impl#[`Cloned<I>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 920 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(alt.interface_numberrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]interface_number().(), 1); |
| 921 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(alt.alternate_settingrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]alternate_setting().(), 6); |
| 922 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(alt.num_endpointsrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]num_endpoints().(), 1); |
| 923 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(alt.classrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]class().(), 14); |
| 924 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(alt.subclassrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]subclass().(), 2); |
| 925 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(alt.protocolrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]protocol().(), 0); |
| 926 | let mut endpoints = alt.endpointsrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`InterfaceAltSetting<'a>`]endpoints().(); |
| 927 | |
| 928 | let endpoint = endpoints.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/map/impl#[`Map<I, F>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 929 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(endpoint.addressrust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Endpoint<'a>`]address().(), 0x81); |
| 930 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(endpoint.transfer_typerust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Endpoint<'a>`]transfer_type().(), EndpointTyperust-analyzer cargo nusb 0.1.13 transfer/EndpointType#::Isochronousrust-analyzer cargo nusb 0.1.13 transfer/EndpointType#Isochronous#); |
| 931 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(endpoint.max_packet_sizerust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Endpoint<'a>`]max_packet_size().(), 1024); |
| 932 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(endpoint.packets_per_microframerust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Endpoint<'a>`]packets_per_microframe().(), 3); |
| 933 | |
| 934 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(endpoints.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/map/impl#[`Map<I, F>`][Iterator]next().().is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().()); |
| 935 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(alts.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/cloned/impl#[`Cloned<I>`][Iterator]next().().is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().()); |
| 936 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(interfaces.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/map/impl#[`Map<I, F>`][Iterator]next().().is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().()); |
| 937 | } |