Fix bytes remaining on stream
This commit is contained in:
1 file changed
+9
@@ -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<Option<Self::Item>> {
|
||||
match self.decode(buf)? {
|
||||
Some(frame) => Ok(Some(frame)),
|
||||
None => Ok(None),
|
||||
}
|
||||
}
|
||||
|
||||
fn decode(&mut self, src: &mut BytesMut) -> Result<Option<Self::Item>> {
|
||||
match { BcUdp::deserialize(src) } {
|
||||
Ok(BcUdp::Discovery(UdpDiscovery {
|
||||
|
||||
Reference in new issue
Block a user