diff --git a/crates/core/src/bcudp/codex.rs b/crates/core/src/bcudp/codex.rs index 74ad60c..747a3ff 100644 --- a/crates/core/src/bcudp/codex.rs +++ b/crates/core/src/bcudp/codex.rs @@ -33,6 +33,15 @@ impl Decoder for BcUdpCodex { type Item = BcUdp; type Error = Error; + /// Since frames can cross EOF boundaries we overload this so it dosen't error if + /// there are bytes left on the stream + fn decode_eof(&mut self, buf: &mut BytesMut) -> Result> { + match self.decode(buf)? { + Some(frame) => Ok(Some(frame)), + None => Ok(None), + } + } + fn decode(&mut self, src: &mut BytesMut) -> Result> { match { BcUdp::deserialize(src) } { Ok(BcUdp::Discovery(UdpDiscovery {