diff --git a/src/io/frame.rs b/src/io/frame.rs index ddda16845..229585322 100644 --- a/src/io/frame.rs +++ b/src/io/frame.rs @@ -242,7 +242,7 @@ pub trait Codec { /// This method will encode `msg` into the byte buffer provided by `buf`. /// The `buf` provided is an internal buffer of the `Framed` instance and /// will be written out when possible. - fn encode(&mut self, msg: Self::Out, buf: &mut Vec); + fn encode(&mut self, msg: Self::Out) -> Result, io::Error>; } /// A unified `Stream` and `Sink` interface to an underlying `Io` object, using @@ -319,7 +319,7 @@ impl Sink for Framed { } } - self.codec.encode(item, &mut self.wr); + self.wr = self.codec.encode(item).unwrap(); Ok(AsyncSink::Ready) }