From 1bbb31f66c831bfe620e74bf392794c367806445 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Sat, 26 Jun 2021 00:16:26 +0600 Subject: [PATCH] use ntex-bytes --- ntex-codec/Cargo.toml | 4 ++-- ntex-codec/src/bcodec.rs | 2 +- ntex-codec/src/decoder.rs | 2 +- ntex-codec/src/encoder.rs | 2 +- ntex-codec/src/framed.rs | 2 +- ntex-codec/src/lib.rs | 7 +++---- 6 files changed, 9 insertions(+), 10 deletions(-) diff --git a/ntex-codec/Cargo.toml b/ntex-codec/Cargo.toml index 30d9766f..ed3bc406 100644 --- a/ntex-codec/Cargo.toml +++ b/ntex-codec/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ntex-codec" -version = "0.4.1" +version = "0.5.0" authors = ["ntex contributors "] description = "Utilities for encoding and decoding frames" keywords = ["network", "framework", "async", "futures"] @@ -17,7 +17,7 @@ path = "src/lib.rs" [dependencies] bitflags = "1.2.1" -bytes = "1.0" +ntex-bytes = "0.5" ntex-util = "0.1.0" log = "0.4" tokio = { version = "1", default-features = false } diff --git a/ntex-codec/src/bcodec.rs b/ntex-codec/src/bcodec.rs index 17223d55..739f3954 100644 --- a/ntex-codec/src/bcodec.rs +++ b/ntex-codec/src/bcodec.rs @@ -1,4 +1,4 @@ -use bytes::{Bytes, BytesMut}; +use ntex_bytes::{Bytes, BytesMut}; use std::io; use super::{Decoder, Encoder}; diff --git a/ntex-codec/src/decoder.rs b/ntex-codec/src/decoder.rs index a5dfec3e..8eabc54e 100644 --- a/ntex-codec/src/decoder.rs +++ b/ntex-codec/src/decoder.rs @@ -1,4 +1,4 @@ -use bytes::BytesMut; +use ntex_bytes::BytesMut; use std::rc::Rc; /// Decoding of frames via buffers. diff --git a/ntex-codec/src/encoder.rs b/ntex-codec/src/encoder.rs index cd8166ce..cd67eeed 100644 --- a/ntex-codec/src/encoder.rs +++ b/ntex-codec/src/encoder.rs @@ -1,4 +1,4 @@ -use bytes::BytesMut; +use ntex_bytes::BytesMut; use std::rc::Rc; /// Trait of helper objects to write out messages as bytes. diff --git a/ntex-codec/src/framed.rs b/ntex-codec/src/framed.rs index f0b20882..e51e0169 100644 --- a/ntex-codec/src/framed.rs +++ b/ntex-codec/src/framed.rs @@ -2,7 +2,7 @@ use std::pin::Pin; use std::task::{Context, Poll}; use std::{fmt, io}; -use bytes::{Buf, BytesMut}; +use ntex_bytes::{Buf, BytesMut}; use ntex_util::{future::Either, ready, Sink, Stream}; use crate::{AsyncRead, AsyncWrite, Decoder, Encoder}; diff --git a/ntex-codec/src/lib.rs b/ntex-codec/src/lib.rs index 83416af8..fc9344b6 100644 --- a/ntex-codec/src/lib.rs +++ b/ntex-codec/src/lib.rs @@ -21,20 +21,19 @@ pub use self::framed::{Framed, FramedParts}; pub use tokio::io::{AsyncRead, AsyncWrite, ReadBuf}; -use bytes::BufMut; +use ntex_bytes::{BufMut, BytesMut}; pub fn poll_read_buf( io: Pin<&mut T>, cx: &mut Context<'_>, - buf: &mut bytes::BytesMut, + buf: &mut BytesMut, ) -> Poll> { if !buf.has_remaining_mut() { return Poll::Ready(Ok(0)); } let n = { - let dst = buf.chunk_mut(); - let dst = unsafe { &mut *(dst as *mut _ as *mut [MaybeUninit]) }; + let dst = unsafe { &mut *(buf.chunk_mut() as *mut _ as *mut [MaybeUninit]) }; let mut buf = ReadBuf::uninit(dst); let ptr = buf.filled().as_ptr(); if io.poll_read(cx, &mut buf)?.is_pending() {