codec: change Encoder to take &Item (#1746)

Co-authored-by: Markus Westerlind <[email protected]>
This commit is contained in:
Lucio Franco
2020-03-04 15:54:41 -05:00
committed by GitHub
co-authored by Markus Westerlind
parent 1eb6131321
commit 9d4d076189
19 changed files with 59 additions and 55 deletions
+2 -5
View File
@@ -5,10 +5,7 @@ use std::io;
/// [`FramedWrite`].
///
/// [`FramedWrite`]: crate::codec::FramedWrite
pub trait Encoder {
/// The type of items consumed by the `Encoder`
type Item;
pub trait Encoder<Item> {
/// The type of encoding errors.
///
/// [`FramedWrite`] requires `Encoder`s errors to implement `From<io::Error>`
@@ -24,5 +21,5 @@ pub trait Encoder {
/// will be written out when possible.
///
/// [`FramedWrite`]: crate::codec::FramedWrite
fn encode(&mut self, item: Self::Item, dst: &mut BytesMut) -> Result<(), Self::Error>;
fn encode(&mut self, item: Item, dst: &mut BytesMut) -> Result<(), Self::Error>;
}