Skip to content

Commit

Permalink
chore: update to bytes 1.0 git branch (#3301)
Browse files Browse the repository at this point in the history
Updates the code base to track the `bytes` git branch. This is in
preparation for the 1.0 release.

Closes #3058
  • Loading branch information
carllerche authored Dec 19, 2020
1 parent 5e5f513 commit 2893359
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion tokio-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion tokio-util/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
2 changes: 1 addition & 1 deletion tokio-util/src/io/stream_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions tokio-util/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u8>]) };
let mut buf = ReadBuf::uninit(dst);
let ptr = buf.filled().as_ptr();
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion tokio-util/src/udp/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl<C: Decoder + Unpin> Stream for UdpFramed<C> {
let addr = unsafe {
// Convert `&mut [MaybeUnit<u8>]` 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<u8>]);
let buf = &mut *(pin.rd.chunk_mut() as *mut _ as *mut [MaybeUninit<u8>]);
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));
Expand Down
2 changes: 1 addition & 1 deletion tokio/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
2 changes: 1 addition & 1 deletion tokio/src/io/util/read_buf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u8>]) };
let mut buf = ReadBuf::uninit(dst);
let ptr = buf.filled().as_ptr();
Expand Down
2 changes: 1 addition & 1 deletion tokio/src/io/util/read_to_end.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ fn reserve(buf: &mut Vec<u8>, bytes: usize) {

/// Returns the unused capacity of the provided vector.
fn get_unused_capacity(buf: &mut Vec<u8>) -> &mut [MaybeUninit<u8>] {
let uninit = bytes::BufMut::bytes_mut(buf);
let uninit = bytes::BufMut::chunk_mut(buf);
unsafe { &mut *(uninit as *mut _ as *mut [MaybeUninit<u8>]) }
}

Expand Down
2 changes: 1 addition & 1 deletion tokio/src/io/util/write_buf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down

0 comments on commit 2893359

Please sign in to comment.