Skip to content

Commit

Permalink
feat(lib): update bytes to 0.6, update http-body (hyperium#2339)
Browse files Browse the repository at this point in the history
This branch updates `bytes` and `http-body` to the latest versions. The
`http-body` version that uses `bytes` 0.6 hasn't been released yet, so
we depend on it via a git dep for now. Presumably Hyper and `http-body`
will synchronize their releases.

Other than that, this is a pretty mechanical update. Should fix the
build and unblock the `h2` update to use vectored writes.
  • Loading branch information
hawkw committed Nov 20, 2020
1 parent ed2b22a commit 751c122
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 8 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ include = [
]

[dependencies]
bytes = "0.5"
bytes = "0.6"
futures-core = { version = "0.3", default-features = false }
futures-channel = "0.3"
futures-util = { version = "0.3", default-features = false }
http = "0.2"
http-body = "0.3.1"
http-body = { git = "https://github.com/hyperium/http-body" }
httpdate = "0.3"
httparse = "1.0"
h2 = { git = "https://github.com/hyperium/h2", optional = true }
Expand Down Expand Up @@ -63,7 +63,7 @@ tokio = { version = "0.3", features = [
"test-util",
] }
tokio-test = "0.3"
tokio-util = { version = "0.4", features = ["codec"] }
tokio-util = { version = "0.5", features = ["codec"] }
tower-util = "0.3"
url = "1.0"

Expand Down
2 changes: 1 addition & 1 deletion examples/client_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#[macro_use]
extern crate serde_derive;

use bytes::buf::BufExt as _;
use bytes::Buf as _;
use hyper::Client;

// A simple type alias so as to DRY.
Expand Down
2 changes: 1 addition & 1 deletion examples/web_api.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![deny(warnings)]

use bytes::buf::BufExt;
use bytes::Buf;
use futures_util::{stream, StreamExt};
use hyper::client::HttpConnector;
use hyper::service::{make_service_fn, service_fn};
Expand Down
2 changes: 1 addition & 1 deletion src/body/to_bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ where
let second = if let Some(buf) = body.data().await {
buf?
} else {
return Ok(first.to_bytes());
return Ok(first.copy_to_bytes(first.bytes().len()));
};

// With more than 1 buf, we gotta flatten into a Vec first.
Expand Down
2 changes: 1 addition & 1 deletion src/proto/h1/encode.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::fmt;
use std::io::IoSlice;

use bytes::buf::ext::{BufExt, Chain, Take};
use bytes::buf::{Chain, Take};
use bytes::Buf;

use super::io::WriteBuf;
Expand Down
6 changes: 5 additions & 1 deletion src/proto/h1/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::cmp;
use std::fmt;
use std::io::{self, IoSlice};
use std::marker::Unpin;
use std::mem::MaybeUninit;

use bytes::{Buf, BufMut, Bytes, BytesMut};
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
Expand Down Expand Up @@ -191,7 +192,10 @@ where
if self.read_buf_remaining_mut() < next {
self.read_buf.reserve(next);
}
let mut buf = ReadBuf::uninit(&mut self.read_buf.bytes_mut()[..]);

let dst = self.read_buf.bytes_mut();
let dst = unsafe { &mut *(dst as *mut _ as *mut [MaybeUninit<u8>]) };
let mut buf = ReadBuf::uninit(dst);
match Pin::new(&mut self.io).poll_read(cx, &mut buf) {
Poll::Ready(Ok(_)) => {
let n = buf.filled().len();
Expand Down

0 comments on commit 751c122

Please sign in to comment.