Allow decode Bc frame over packet boundary

This commit is contained in:
QuantumEntangledAndy committed 2023-05-03 20:26:13 +07:00
1 parent e2602b5c17
commit 386fec4220
1 file changed
+15 -11
+15 -11
View File
@@ -48,19 +48,23 @@ impl Decoder for BcCodex {
type Error = Error;
fn decode_eof(&mut self, buf: &mut BytesMut) -> Result<Option<Self::Item>> {
// match self.decode(buf)? {
// Some(frame) => Ok(Some(frame)),
// None => {
// if buf.is_empty() {
// Ok(None)
// } else {
// Err(io::Error::new(
// io::ErrorKind::Other,
// format!("bytes remaining on BC stream: {:X?}", buf),
// )
// .into())
// }
// }
// }
match self.decode(buf)? {
Some(frame) => Ok(Some(frame)),
None => {
if buf.is_empty() {
Ok(None)
} else {
Err(io::Error::new(
io::ErrorKind::Other,
format!("bytes remaining on BC stream: {:X?}", buf),
)
.into())
}
}
None => Ok(None),
}
}