mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-21 22:32:29 +00:00
Merge pull request #3296 from maximevince/embassy-usb-empty-bos-desc
Allow bos_descriptor_buf to be a zero-length slice
This commit is contained in:
commit
e535676fa2
@ -308,6 +308,9 @@ impl<'a> BosWriter<'a> {
|
||||
}
|
||||
|
||||
pub(crate) fn bos(&mut self) {
|
||||
if (self.writer.buf.len() - self.writer.position) < 5 {
|
||||
return;
|
||||
}
|
||||
self.num_caps_mark = Some(self.writer.position + 4);
|
||||
self.writer.write(
|
||||
descriptor_type::BOS,
|
||||
@ -350,6 +353,9 @@ impl<'a> BosWriter<'a> {
|
||||
}
|
||||
|
||||
pub(crate) fn end_bos(&mut self) {
|
||||
if self.writer.position == 0 {
|
||||
return;
|
||||
}
|
||||
self.num_caps_mark = None;
|
||||
let position = self.writer.position as u16;
|
||||
self.writer.buf[2..4].copy_from_slice(&position.to_le_bytes());
|
||||
|
Loading…
Reference in New Issue
Block a user