use ntex-bytes

This commit is contained in:
Nikolay Kim 2021-06-26 00:16:26 +06:00
parent 45463f209b
commit 1bbb31f66c
6 changed files with 9 additions and 10 deletions

View file

@ -1,6 +1,6 @@
[package]
name = "ntex-codec"
version = "0.4.1"
version = "0.5.0"
authors = ["ntex contributors <team@ntex.rs>"]
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 }

View file

@ -1,4 +1,4 @@
use bytes::{Bytes, BytesMut};
use ntex_bytes::{Bytes, BytesMut};
use std::io;
use super::{Decoder, Encoder};

View file

@ -1,4 +1,4 @@
use bytes::BytesMut;
use ntex_bytes::BytesMut;
use std::rc::Rc;
/// Decoding of frames via buffers.

View file

@ -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.

View file

@ -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};

View file

@ -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<T: AsyncRead>(
io: Pin<&mut T>,
cx: &mut Context<'_>,
buf: &mut bytes::BytesMut,
buf: &mut BytesMut,
) -> Poll<io::Result<usize>> {
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<u8>]) };
let dst = unsafe { &mut *(buf.chunk_mut() as *mut _ as *mut [MaybeUninit<u8>]) };
let mut buf = ReadBuf::uninit(dst);
let ptr = buf.filled().as_ptr();
if io.poll_read(cx, &mut buf)?.is_pending() {