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
+3 -4
View File
@@ -42,7 +42,6 @@ const BACKPRESSURE_BOUNDARY: usize = INITIAL_CAPACITY;
impl<T, E> FramedWrite<T, E>
where
T: AsyncWrite,
E: Encoder,
{
/// Creates a new `FramedWrite` with the given `encoder`.
pub fn new(inner: T, encoder: E) -> FramedWrite<T, E> {
@@ -100,7 +99,7 @@ impl<T, E> FramedWrite<T, E> {
impl<T, I, E> Sink<I> for FramedWrite<T, E>
where
T: AsyncWrite,
E: Encoder<Item = I>,
E: Encoder<I>,
E::Error: From<io::Error>,
{
type Error = E::Error;
@@ -191,9 +190,9 @@ impl<T> FramedWrite2<T> {
impl<I, T> Sink<I> for FramedWrite2<T>
where
T: ProjectFuse + AsyncWrite,
T::Codec: Encoder<Item = I>,
T::Codec: Encoder<I>,
{
type Error = <T::Codec as Encoder>::Error;
type Error = <T::Codec as Encoder<I>>::Error;
fn poll_ready(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
// If the buffer is already over 8KiB, then attempt to flush it. If after flushing it's