From 386fec422073f08b08ef567c9695e84204fd00cf Mon Sep 17 00:00:00 2001 From: QuantumEntangledAndy Date: Wed, 3 May 2023 20:26:13 +0700 Subject: [PATCH] Allow decode Bc frame over packet boundary --- crates/core/src/bc/codex.rs | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/crates/core/src/bc/codex.rs b/crates/core/src/bc/codex.rs index 203a143..6ad3525 100644 --- a/crates/core/src/bc/codex.rs +++ b/crates/core/src/bc/codex.rs @@ -48,19 +48,23 @@ impl Decoder for BcCodex { type Error = Error; fn decode_eof(&mut self, buf: &mut BytesMut) -> Result> { + // 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), } }