Remove Report descriptor structure
Report descriptors lack the 2 byte header other descriptors have and can't be parsed like the rest.
This commit is contained in:
@ -3,7 +3,6 @@ mod device;
|
|||||||
mod endpoint;
|
mod endpoint;
|
||||||
mod hid;
|
mod hid;
|
||||||
mod interface;
|
mod interface;
|
||||||
mod report;
|
|
||||||
mod string;
|
mod string;
|
||||||
|
|
||||||
pub use configuration::*;
|
pub use configuration::*;
|
||||||
@ -11,7 +10,6 @@ pub use device::*;
|
|||||||
pub use endpoint::*;
|
pub use endpoint::*;
|
||||||
pub use hid::*;
|
pub use hid::*;
|
||||||
pub use interface::*;
|
pub use interface::*;
|
||||||
pub use report::*;
|
|
||||||
pub use string::*;
|
pub use string::*;
|
||||||
|
|
||||||
use core::mem;
|
use core::mem;
|
||||||
@ -49,7 +47,6 @@ pub enum Descriptor<'a> {
|
|||||||
Interface(Interface),
|
Interface(Interface),
|
||||||
Endpoint(Endpoint),
|
Endpoint(Endpoint),
|
||||||
Hid(Hid),
|
Hid(Hid),
|
||||||
Report(Report<'a>),
|
|
||||||
Unknown { ty: u8, data: &'a [u8] },
|
Unknown { ty: u8, data: &'a [u8] },
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,9 +141,6 @@ impl<'a> Iterator for Iter<'a> {
|
|||||||
Endpoint::from_raw(b).map_err(InvalidDescriptor::Endpoint)?,
|
Endpoint::from_raw(b).map_err(InvalidDescriptor::Endpoint)?,
|
||||||
),
|
),
|
||||||
HID => Descriptor::Hid(Hid::from_raw(b).map_err(InvalidDescriptor::Hid)?),
|
HID => Descriptor::Hid(Hid::from_raw(b).map_err(InvalidDescriptor::Hid)?),
|
||||||
REPORT => {
|
|
||||||
Descriptor::Report(Report::from_raw(b).map_err(InvalidDescriptor::Report)?)
|
|
||||||
}
|
|
||||||
ty => Descriptor::Unknown { ty, data: b },
|
ty => Descriptor::Unknown { ty, data: b },
|
||||||
};
|
};
|
||||||
self.buf = &buf[usize::from(l)..];
|
self.buf = &buf[usize::from(l)..];
|
||||||
@ -164,5 +158,4 @@ pub enum InvalidDescriptor {
|
|||||||
Interface(InvalidInterface),
|
Interface(InvalidInterface),
|
||||||
Endpoint(InvalidEndpoint),
|
Endpoint(InvalidEndpoint),
|
||||||
Hid(InvalidHid),
|
Hid(InvalidHid),
|
||||||
Report(InvalidReport),
|
|
||||||
}
|
}
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
use core::fmt;
|
|
||||||
|
|
||||||
pub struct Report<'a> {
|
|
||||||
pub data: &'a [u8],
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> Report<'a> {
|
|
||||||
pub(crate) fn from_raw(data: &'a [u8]) -> Result<Self, InvalidReport> {
|
|
||||||
Ok(Self { data })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl fmt::Debug for Report<'_> {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
||||||
f.debug_struct(stringify!(Report))
|
|
||||||
.field("data", &format_args!("{:02x?}", self.data))
|
|
||||||
.finish()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub enum InvalidReport {}
|
|
Reference in New Issue
Block a user