mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-22 06:42:32 +00:00
Allow bos_descriptor_buf to be a zero-length slice
This commit is contained in:
parent
f0a8607051
commit
abcb39a58b
@ -308,6 +308,9 @@ impl<'a> BosWriter<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn bos(&mut self) {
|
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.num_caps_mark = Some(self.writer.position + 4);
|
||||||
self.writer.write(
|
self.writer.write(
|
||||||
descriptor_type::BOS,
|
descriptor_type::BOS,
|
||||||
@ -350,6 +353,9 @@ impl<'a> BosWriter<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn end_bos(&mut self) {
|
pub(crate) fn end_bos(&mut self) {
|
||||||
|
if self.writer.position == 0 {
|
||||||
|
return;
|
||||||
|
}
|
||||||
self.num_caps_mark = None;
|
self.num_caps_mark = None;
|
||||||
let position = self.writer.position as u16;
|
let position = self.writer.position as u16;
|
||||||
self.writer.buf[2..4].copy_from_slice(&position.to_le_bytes());
|
self.writer.buf[2..4].copy_from_slice(&position.to_le_bytes());
|
||||||
|
Loading…
Reference in New Issue
Block a user