1
0
mirror of https://github.com/fafhrd91/actix-net synced 2025-08-31 08:26:59 +02:00

use bitflags for internal flags; use tokio 0.2

This commit is contained in:
Nikolay Kim
2019-12-05 13:11:56 +06:00
parent 6f41b80cb4
commit d49aca9595
5 changed files with 50 additions and 90 deletions

View File

@@ -1,7 +1,7 @@
use bytes::{BufMut, Bytes, BytesMut};
use std::io;
use bytes::{Bytes, BytesMut};
use tokio_codec::{Decoder, Encoder};
use super::{Decoder, Encoder};
/// Bytes codec.
///
@@ -14,7 +14,8 @@ impl Encoder for BytesCodec {
type Error = io::Error;
fn encode(&mut self, item: Bytes, dst: &mut BytesMut) -> Result<(), Self::Error> {
dst.extend_from_slice(&item[..]);
dst.reserve(item.len());
dst.put(item);
Ok(())
}
}
@@ -27,7 +28,8 @@ impl Decoder for BytesCodec {
if src.is_empty() {
Ok(None)
} else {
Ok(Some(src.take()))
let len = src.len();
Ok(Some(src.split_to(len)))
}
}
}