From e8fcd34476c7291a2fb84c8293e6ef9709745da4 Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Fri, 27 Apr 2018 14:35:28 -0700 Subject: [PATCH] change from deprecated Buf::put_* to put_*_be (#267) --- Cargo.toml | 2 +- src/frame/go_away.rs | 6 +++--- src/frame/head.rs | 6 +++--- src/frame/headers.rs | 2 +- src/frame/reset.rs | 4 ++-- src/frame/settings.rs | 6 +++--- src/frame/window_update.rs | 4 ++-- tests/stream_states.rs | 5 ++--- 8 files changed, 17 insertions(+), 18 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5277a80..3090432 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,7 +32,7 @@ unstable = [] [dependencies] futures = "0.1" tokio-io = "0.1.4" -bytes = "0.4" +bytes = "0.4.7" http = "0.1.3" byteorder = "1.0" log = "0.4.1" diff --git a/src/frame/go_away.rs b/src/frame/go_away.rs index f81147e..d97f04f 100644 --- a/src/frame/go_away.rs +++ b/src/frame/go_away.rs @@ -1,6 +1,6 @@ use frame::{self, Error, Head, Kind, Reason, StreamId}; -use bytes::{BigEndian, BufMut}; +use bytes::{BufMut}; #[derive(Debug, Clone, Copy, Eq, PartialEq)] pub struct GoAway { @@ -42,8 +42,8 @@ impl GoAway { trace!("encoding GO_AWAY; code={:?}", self.error_code); let head = Head::new(Kind::GoAway, 0, StreamId::zero()); head.encode(8, dst); - dst.put_u32::(self.last_stream_id.into()); - dst.put_u32::(self.error_code.into()); + dst.put_u32_be(self.last_stream_id.into()); + dst.put_u32_be(self.error_code.into()); } } diff --git a/src/frame/head.rs b/src/frame/head.rs index 7050c6e..a72c5b3 100644 --- a/src/frame/head.rs +++ b/src/frame/head.rs @@ -1,6 +1,6 @@ use super::StreamId; -use bytes::{BigEndian, BufMut}; +use bytes::{BufMut}; #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub struct Head { @@ -66,10 +66,10 @@ impl Head { pub fn encode(&self, payload_len: usize, dst: &mut T) { debug_assert!(self.encode_len() <= dst.remaining_mut()); - dst.put_uint::(payload_len as u64, 3); + dst.put_uint_be(payload_len as u64, 3); dst.put_u8(self.kind as u8); dst.put_u8(self.flag); - dst.put_u32::(self.stream_id.into()); + dst.put_u32_be(self.stream_id.into()); } } diff --git a/src/frame/headers.rs b/src/frame/headers.rs index f843c69..d30374e 100644 --- a/src/frame/headers.rs +++ b/src/frame/headers.rs @@ -371,7 +371,7 @@ impl PushPromise { self.header_block.into_encoding() .encode(&head, encoder, dst, |dst| { - dst.put_u32::(promised_id.into()); + dst.put_u32_be(promised_id.into()); }) } diff --git a/src/frame/reset.rs b/src/frame/reset.rs index be22a1f..c5e6ae2 100644 --- a/src/frame/reset.rs +++ b/src/frame/reset.rs @@ -1,6 +1,6 @@ use frame::{self, Error, Head, Kind, Reason, StreamId}; -use bytes::{BigEndian, BufMut}; +use bytes::{BufMut}; #[derive(Debug, Eq, PartialEq)] pub struct Reset { @@ -45,7 +45,7 @@ impl Reset { ); let head = Head::new(Kind::Reset, 0, self.stream_id); head.encode(4, dst); - dst.put_u32::(self.error_code.into()); + dst.put_u32_be(self.error_code.into()); } } diff --git a/src/frame/settings.rs b/src/frame/settings.rs index 90fd493..c91a719 100644 --- a/src/frame/settings.rs +++ b/src/frame/settings.rs @@ -1,4 +1,4 @@ -use bytes::{BigEndian, BufMut, BytesMut}; +use bytes::{BufMut, BytesMut}; use frame::{Error, Frame, FrameSize, Head, Kind, StreamId}; #[derive(Debug, Clone, Default, Eq, PartialEq)] @@ -280,8 +280,8 @@ impl Setting { MaxHeaderListSize(v) => (6, v), }; - dst.put_u16::(kind); - dst.put_u32::(val); + dst.put_u16_be(kind); + dst.put_u32_be(val); } } diff --git a/src/frame/window_update.rs b/src/frame/window_update.rs index 3488ac3..687e079 100644 --- a/src/frame/window_update.rs +++ b/src/frame/window_update.rs @@ -1,6 +1,6 @@ use frame::{self, Error, Head, Kind, StreamId}; -use bytes::{BigEndian, BufMut}; +use bytes::{BufMut}; const SIZE_INCREMENT_MASK: u32 = 1 << 31; @@ -51,7 +51,7 @@ impl WindowUpdate { trace!("encoding WINDOW_UPDATE; id={:?}", self.stream_id); let head = Head::new(Kind::WindowUpdate, 0, self.stream_id); head.encode(4, dst); - dst.put_u32::(self.size_increment); + dst.put_u32_be(self.size_increment); } } diff --git a/tests/stream_states.rs b/tests/stream_states.rs index a1f2754..c48d66c 100644 --- a/tests/stream_states.rs +++ b/tests/stream_states.rs @@ -1,3 +1,4 @@ +#![deny(warnings)] #[macro_use] extern crate log; @@ -881,8 +882,6 @@ fn rst_while_closing() { #[test] fn rst_with_buffered_data() { - use futures::future::lazy; - // Data is buffered in `FramedWrite` and the stream is reset locally before // the data is fully flushed. Given that resetting a stream requires // clearing all associated state for that stream, this test ensures that the @@ -932,7 +931,7 @@ fn rst_with_buffered_data() { stream.send_data(body.into(), true).unwrap(); conn.drive({ - resp.then(|res| { + resp.then(|_res| { Ok::<_, ()>(()) }) })