diff --git a/examples/Cargo.toml b/examples/Cargo.toml index fc35e60f303..2c1f7f9257c 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -14,7 +14,7 @@ tokio-stream = { version = "0.1", path = "../tokio-stream" } async-stream = "0.3" tracing = "0.1" tracing-subscriber = { version = "0.2.7", default-features = false, features = ["fmt", "ansi", "env-filter", "chrono", "tracing-log"] } -bytes = "0.6" +bytes = { git = "https://github.com/tokio-rs/bytes" } futures = "0.3.0" http = "0.2" serde = "1.0" diff --git a/tokio-test/Cargo.toml b/tokio-test/Cargo.toml index 69db2055301..6c9b0862c3f 100644 --- a/tokio-test/Cargo.toml +++ b/tokio-test/Cargo.toml @@ -25,7 +25,7 @@ tokio = { version = "1.0.0", path = "../tokio", features = ["rt", "sync", "time" tokio-stream = { version = "0.1", path = "../tokio-stream" } async-stream = "0.3" -bytes = "0.6.0" +bytes = { git = "https://github.com/tokio-rs/bytes" } futures-core = "0.3.0" [dev-dependencies] diff --git a/tokio-util/Cargo.toml b/tokio-util/Cargo.toml index 2df37585e13..1b725b404b4 100644 --- a/tokio-util/Cargo.toml +++ b/tokio-util/Cargo.toml @@ -40,7 +40,7 @@ __docs_rs = ["futures-util"] tokio = { version = "1.0.0", path = "../tokio" } tokio-stream = { version = "0.1", path = "../tokio-stream" } -bytes = "0.6.0" +bytes = { git = "https://github.com/tokio-rs/bytes" } futures-core = "0.3.0" futures-sink = "0.3.0" futures-io = { version = "0.3.0", optional = true } diff --git a/tokio-util/src/io/stream_reader.rs b/tokio-util/src/io/stream_reader.rs index 12820de4af0..a35ae67f39f 100644 --- a/tokio-util/src/io/stream_reader.rs +++ b/tokio-util/src/io/stream_reader.rs @@ -131,7 +131,7 @@ where loop { if self.as_mut().has_chunk() { // This unwrap is very sad, but it can't be avoided. - let buf = self.project().chunk.as_ref().unwrap().bytes(); + let buf = self.project().chunk.as_ref().unwrap().chunk(); return Poll::Ready(Ok(buf)); } else { match self.as_mut().project().inner.poll_next(cx) { diff --git a/tokio-util/src/lib.rs b/tokio-util/src/lib.rs index 999598c7a94..065c6298b68 100644 --- a/tokio-util/src/lib.rs +++ b/tokio-util/src/lib.rs @@ -113,7 +113,7 @@ mod util { } let n = { - let dst = buf.bytes_mut(); + let dst = buf.chunk_mut(); let dst = unsafe { &mut *(dst as *mut _ as *mut [MaybeUninit]) }; let mut buf = ReadBuf::uninit(dst); let ptr = buf.filled().as_ptr(); @@ -187,10 +187,10 @@ mod util { let n = if io.is_write_vectored() { let mut slices = [IoSlice::new(&[]); MAX_BUFS]; - let cnt = buf.bytes_vectored(&mut slices); + let cnt = buf.chunks_vectored(&mut slices); ready!(io.poll_write_vectored(cx, &slices[..cnt]))? } else { - ready!(io.poll_write(cx, buf.bytes()))? + ready!(io.poll_write(cx, buf.chunk()))? }; buf.advance(n); diff --git a/tokio-util/src/udp/frame.rs b/tokio-util/src/udp/frame.rs index b4ef3ca8c77..eafe7f91398 100644 --- a/tokio-util/src/udp/frame.rs +++ b/tokio-util/src/udp/frame.rs @@ -76,7 +76,7 @@ impl Stream for UdpFramed { let addr = unsafe { // Convert `&mut [MaybeUnit]` to `&mut [u8]` because we will be // writing to it via `poll_recv_from` and therefore initializing the memory. - let buf = &mut *(pin.rd.bytes_mut() as *mut _ as *mut [MaybeUninit]); + let buf = &mut *(pin.rd.chunk_mut() as *mut _ as *mut [MaybeUninit]); let mut read = ReadBuf::uninit(buf); let ptr = read.filled().as_ptr(); let res = ready!(Pin::new(&mut pin.socket).poll_recv_from(cx, &mut read)); diff --git a/tokio/Cargo.toml b/tokio/Cargo.toml index 817c619a8fe..2750a6d3128 100644 --- a/tokio/Cargo.toml +++ b/tokio/Cargo.toml @@ -92,7 +92,7 @@ tokio-macros = { version = "1.0.0", path = "../tokio-macros", optional = true } pin-project-lite = "0.2.0" # Everything else is optional... -bytes = { version = "0.6.0", optional = true } +bytes = { git = "https://github.com/tokio-rs/bytes", optional = true } once_cell = { version = "1.5.2", optional = true } memchr = { version = "2.2", optional = true } mio = { version = "0.7.6", optional = true } diff --git a/tokio/src/io/util/read_buf.rs b/tokio/src/io/util/read_buf.rs index 696deefd1e6..8ec57c0d6f6 100644 --- a/tokio/src/io/util/read_buf.rs +++ b/tokio/src/io/util/read_buf.rs @@ -50,7 +50,7 @@ where } let n = { - let dst = me.buf.bytes_mut(); + let dst = me.buf.chunk_mut(); let dst = unsafe { &mut *(dst as *mut _ as *mut [MaybeUninit]) }; let mut buf = ReadBuf::uninit(dst); let ptr = buf.filled().as_ptr(); diff --git a/tokio/src/io/util/read_to_end.rs b/tokio/src/io/util/read_to_end.rs index a97462594bc..f40d148e2af 100644 --- a/tokio/src/io/util/read_to_end.rs +++ b/tokio/src/io/util/read_to_end.rs @@ -98,7 +98,7 @@ fn reserve(buf: &mut Vec, bytes: usize) { /// Returns the unused capacity of the provided vector. fn get_unused_capacity(buf: &mut Vec) -> &mut [MaybeUninit] { - let uninit = bytes::BufMut::bytes_mut(buf); + let uninit = bytes::BufMut::chunk_mut(buf); unsafe { &mut *(uninit as *mut _ as *mut [MaybeUninit]) } } diff --git a/tokio/src/io/util/write_buf.rs b/tokio/src/io/util/write_buf.rs index 1310e5c1b25..82fd7a759f6 100644 --- a/tokio/src/io/util/write_buf.rs +++ b/tokio/src/io/util/write_buf.rs @@ -48,7 +48,7 @@ where return Poll::Ready(Ok(0)); } - let n = ready!(Pin::new(me.writer).poll_write(cx, me.buf.bytes()))?; + let n = ready!(Pin::new(me.writer).poll_write(cx, me.buf.chunk()))?; me.buf.advance(n); Poll::Ready(Ok(n)) }