aboutsummaryrefslogtreecommitdiff
path: root/src/buf
diff options
context:
space:
mode:
Diffstat (limited to 'src/buf')
-rw-r--r--src/buf/buf.rs140
-rw-r--r--src/buf/buf_mut.rs138
-rw-r--r--src/buf/chain.rs6
-rw-r--r--src/buf/into_buf.rs8
4 files changed, 66 insertions, 226 deletions
diff --git a/src/buf/buf.rs b/src/buf/buf.rs
index dc20567..3b4096f 100644
--- a/src/buf/buf.rs
+++ b/src/buf/buf.rs
@@ -146,7 +146,7 @@ pub trait Buf {
/// with `dst` being a zero length slice.
///
/// [`writev`]: http://man7.org/linux/man-pages/man2/readv.2.html
- fn bytes_vec<'a>(&'a self, dst: &mut [&'a IoVec]) -> usize {
+ fn bytes_vec<'a>(&'a self, dst: &mut [IoVec<'a>]) -> usize {
if dst.is_empty() {
return 0;
}
@@ -251,7 +251,7 @@ pub trait Buf {
ptr::copy_nonoverlapping(
src.as_ptr(), dst[off..].as_mut_ptr(), cnt);
- off += src.len();
+ off += cnt;
}
self.advance(cnt);
@@ -306,14 +306,6 @@ pub trait Buf {
ret
}
- #[doc(hidden)]
- #[deprecated(note="use get_u16_be or get_u16_le")]
- fn get_u16<T: ByteOrder>(&mut self) -> u16 where Self: Sized {
- let mut buf = [0; 2];
- self.copy_to_slice(&mut buf);
- T::read_u16(&buf)
- }
-
/// Gets an unsigned 16 bit integer from `self` in big-endian byte order.
///
/// The current position is advanced by 2.
@@ -325,13 +317,13 @@ pub trait Buf {
/// use std::io::Cursor;
///
/// let mut buf = Cursor::new(b"\x08\x09 hello");
- /// assert_eq!(0x0809, buf.get_u16_be());
+ /// assert_eq!(0x0809, buf.get_u16());
/// ```
///
/// # Panics
///
/// This function panics if there is not enough remaining data in `self`.
- fn get_u16_be(&mut self) -> u16 {
+ fn get_u16(&mut self) -> u16 {
buf_get_impl!(self, 2, BigEndian::read_u16);
}
@@ -356,14 +348,6 @@ pub trait Buf {
buf_get_impl!(self, 2, LittleEndian::read_u16);
}
- #[doc(hidden)]
- #[deprecated(note="use get_i16_be or get_i16_le")]
- fn get_i16<T: ByteOrder>(&mut self) -> i16 where Self: Sized {
- let mut buf = [0; 2];
- self.copy_to_slice(&mut buf);
- T::read_i16(&buf)
- }
-
/// Gets a signed 16 bit integer from `self` in big-endian byte order.
///
/// The current position is advanced by 2.
@@ -375,13 +359,13 @@ pub trait Buf {
/// use std::io::Cursor;
///
/// let mut buf = Cursor::new(b"\x08\x09 hello");
- /// assert_eq!(0x0809, buf.get_i16_be());
+ /// assert_eq!(0x0809, buf.get_i16());
/// ```
///
/// # Panics
///
/// This function panics if there is not enough remaining data in `self`.
- fn get_i16_be(&mut self) -> i16 {
+ fn get_i16(&mut self) -> i16 {
buf_get_impl!(self, 2, BigEndian::read_i16);
}
@@ -406,14 +390,6 @@ pub trait Buf {
buf_get_impl!(self, 2, LittleEndian::read_i16);
}
- #[doc(hidden)]
- #[deprecated(note="use get_u32_be or get_u32_le")]
- fn get_u32<T: ByteOrder>(&mut self) -> u32 where Self: Sized {
- let mut buf = [0; 4];
- self.copy_to_slice(&mut buf);
- T::read_u32(&buf)
- }
-
/// Gets an unsigned 32 bit integer from `self` in the big-endian byte order.
///
/// The current position is advanced by 4.
@@ -425,13 +401,13 @@ pub trait Buf {
/// use std::io::Cursor;
///
/// let mut buf = Cursor::new(b"\x08\x09\xA0\xA1 hello");
- /// assert_eq!(0x0809A0A1, buf.get_u32_be());
+ /// assert_eq!(0x0809A0A1, buf.get_u32());
/// ```
///
/// # Panics
///
/// This function panics if there is not enough remaining data in `self`.
- fn get_u32_be(&mut self) -> u32 {
+ fn get_u32(&mut self) -> u32 {
buf_get_impl!(self, 4, BigEndian::read_u32);
}
@@ -456,14 +432,6 @@ pub trait Buf {
buf_get_impl!(self, 4, LittleEndian::read_u32);
}
- #[doc(hidden)]
- #[deprecated(note="use get_i32_be or get_i32_le")]
- fn get_i32<T: ByteOrder>(&mut self) -> i32 where Self: Sized {
- let mut buf = [0; 4];
- self.copy_to_slice(&mut buf);
- T::read_i32(&buf)
- }
-
/// Gets a signed 32 bit integer from `self` in big-endian byte order.
///
/// The current position is advanced by 4.
@@ -475,13 +443,13 @@ pub trait Buf {
/// use std::io::Cursor;
///
/// let mut buf = Cursor::new(b"\x08\x09\xA0\xA1 hello");
- /// assert_eq!(0x0809A0A1, buf.get_i32_be());
+ /// assert_eq!(0x0809A0A1, buf.get_i32());
/// ```
///
/// # Panics
///
/// This function panics if there is not enough remaining data in `self`.
- fn get_i32_be(&mut self) -> i32 {
+ fn get_i32(&mut self) -> i32 {
buf_get_impl!(self, 4, BigEndian::read_i32);
}
@@ -506,14 +474,6 @@ pub trait Buf {
buf_get_impl!(self, 4, LittleEndian::read_i32);
}
- #[doc(hidden)]
- #[deprecated(note="use get_u64_be or get_u64_le")]
- fn get_u64<T: ByteOrder>(&mut self) -> u64 where Self: Sized {
- let mut buf = [0; 8];
- self.copy_to_slice(&mut buf);
- T::read_u64(&buf)
- }
-
/// Gets an unsigned 64 bit integer from `self` in big-endian byte order.
///
/// The current position is advanced by 8.
@@ -525,13 +485,13 @@ pub trait Buf {
/// use std::io::Cursor;
///
/// let mut buf = Cursor::new(b"\x01\x02\x03\x04\x05\x06\x07\x08 hello");
- /// assert_eq!(0x0102030405060708, buf.get_u64_be());
+ /// assert_eq!(0x0102030405060708, buf.get_u64());
/// ```
///
/// # Panics
///
/// This function panics if there is not enough remaining data in `self`.
- fn get_u64_be(&mut self) -> u64 {
+ fn get_u64(&mut self) -> u64 {
buf_get_impl!(self, 8, BigEndian::read_u64);
}
@@ -556,14 +516,6 @@ pub trait Buf {
buf_get_impl!(self, 8, LittleEndian::read_u64);
}
- #[doc(hidden)]
- #[deprecated(note="use get_i64_be or get_i64_le")]
- fn get_i64<T: ByteOrder>(&mut self) -> i64 where Self: Sized {
- let mut buf = [0; 8];
- self.copy_to_slice(&mut buf);
- T::read_i64(&buf)
- }
-
/// Gets a signed 64 bit integer from `self` in big-endian byte order.
///
/// The current position is advanced by 8.
@@ -575,13 +527,13 @@ pub trait Buf {
/// use std::io::Cursor;
///
/// let mut buf = Cursor::new(b"\x01\x02\x03\x04\x05\x06\x07\x08 hello");
- /// assert_eq!(0x0102030405060708, buf.get_i64_be());
+ /// assert_eq!(0x0102030405060708, buf.get_i64());
/// ```
///
/// # Panics
///
/// This function panics if there is not enough remaining data in `self`.
- fn get_i64_be(&mut self) -> i64 {
+ fn get_i64(&mut self) -> i64 {
buf_get_impl!(self, 8, BigEndian::read_i64);
}
@@ -618,14 +570,14 @@ pub trait Buf {
/// use std::io::Cursor;
///
/// let mut buf = Cursor::new(b"\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10\x11\x12\x13\x14\x15\x16 hello");
- /// assert_eq!(0x01020304050607080910111213141516, buf.get_u128_be());
+ /// assert_eq!(0x01020304050607080910111213141516, buf.get_u128());
/// ```
///
/// # Panics
///
/// This function panics if there is not enough remaining data in `self`.
#[cfg(feature = "i128")]
- fn get_u128_be(&mut self) -> u128 {
+ fn get_u128(&mut self) -> u128 {
buf_get_impl!(self, 16, BigEndian::read_u128);
}
@@ -664,14 +616,14 @@ pub trait Buf {
/// use std::io::Cursor;
///
/// let mut buf = Cursor::new(b"\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10\x11\x12\x13\x14\x15\x16 hello");
- /// assert_eq!(0x01020304050607080910111213141516, buf.get_i128_be());
+ /// assert_eq!(0x01020304050607080910111213141516, buf.get_i128());
/// ```
///
/// # Panics
///
/// This function panics if there is not enough remaining data in `self`.
#[cfg(feature = "i128")]
- fn get_i128_be(&mut self) -> i128 {
+ fn get_i128(&mut self) -> i128 {
buf_get_impl!(self, 16, BigEndian::read_i128);
}
@@ -698,14 +650,6 @@ pub trait Buf {
buf_get_impl!(self, 16, LittleEndian::read_i128);
}
- #[doc(hidden)]
- #[deprecated(note="use get_uint_be or get_uint_le")]
- fn get_uint<T: ByteOrder>(&mut self, nbytes: usize) -> u64 where Self: Sized {
- let mut buf = [0; 8];
- self.copy_to_slice(&mut buf[..nbytes]);
- T::read_uint(&buf[..nbytes], nbytes)
- }
-
/// Gets an unsigned n-byte integer from `self` in big-endian byte order.
///
/// The current position is advanced by `nbytes`.
@@ -713,17 +657,17 @@ pub trait Buf {
/// # Examples
///
/// ```
- /// use bytes::{Buf, BigEndian};
+ /// use bytes::Buf;
/// use std::io::Cursor;
///
/// let mut buf = Cursor::new(b"\x01\x02\x03 hello");
- /// assert_eq!(0x010203, buf.get_uint_be(3));
+ /// assert_eq!(0x010203, buf.get_uint(3));
/// ```
///
/// # Panics
///
/// This function panics if there is not enough remaining data in `self`.
- fn get_uint_be(&mut self, nbytes: usize) -> u64 {
+ fn get_uint(&mut self, nbytes: usize) -> u64 {
buf_get_impl!(self, 8, BigEndian::read_uint, nbytes);
}
@@ -748,14 +692,6 @@ pub trait Buf {
buf_get_impl!(self, 8, LittleEndian::read_uint, nbytes);
}
- #[doc(hidden)]
- #[deprecated(note="use get_int_be or get_int_le")]
- fn get_int<T: ByteOrder>(&mut self, nbytes: usize) -> i64 where Self: Sized {
- let mut buf = [0; 8];
- self.copy_to_slice(&mut buf[..nbytes]);
- T::read_int(&buf[..nbytes], nbytes)
- }
-
/// Gets a signed n-byte integer from `self` in big-endian byte order.
///
/// The current position is advanced by `nbytes`.
@@ -767,13 +703,13 @@ pub trait Buf {
/// use std::io::Cursor;
///
/// let mut buf = Cursor::new(b"\x01\x02\x03 hello");
- /// assert_eq!(0x010203, buf.get_int_be(3));
+ /// assert_eq!(0x010203, buf.get_int(3));
/// ```
///
/// # Panics
///
/// This function panics if there is not enough remaining data in `self`.
- fn get_int_be(&mut self, nbytes: usize) -> i64 {
+ fn get_int(&mut self, nbytes: usize) -> i64 {
buf_get_impl!(self, 8, BigEndian::read_int, nbytes);
}
@@ -798,14 +734,6 @@ pub trait Buf {
buf_get_impl!(self, 8, LittleEndian::read_int, nbytes);
}
- #[doc(hidden)]
- #[deprecated(note="use get_f32_be or get_f32_le")]
- fn get_f32<T: ByteOrder>(&mut self) -> f32 where Self: Sized {
- let mut buf = [0; 4];
- self.copy_to_slice(&mut buf);
- T::read_f32(&buf)
- }
-
/// Gets an IEEE754 single-precision (4 bytes) floating point number from
/// `self` in big-endian byte order.
///
@@ -818,13 +746,13 @@ pub trait Buf {
/// use std::io::Cursor;
///
/// let mut buf = Cursor::new(b"\x3F\x99\x99\x9A hello");
- /// assert_eq!(1.2f32, buf.get_f32_be());
+ /// assert_eq!(1.2f32, buf.get_f32());
/// ```
///
/// # Panics
///
/// This function panics if there is not enough remaining data in `self`.
- fn get_f32_be(&mut self) -> f32 {
+ fn get_f32(&mut self) -> f32 {
buf_get_impl!(self, 4, BigEndian::read_f32);
}
@@ -850,14 +778,6 @@ pub trait Buf {
buf_get_impl!(self, 4, LittleEndian::read_f32);
}
- #[doc(hidden)]
- #[deprecated(note="use get_f64_be or get_f64_le")]
- fn get_f64<T: ByteOrder>(&mut self) -> f64 where Self: Sized {
- let mut buf = [0; 8];
- self.copy_to_slice(&mut buf);
- T::read_f64(&buf)
- }
-
/// Gets an IEEE754 double-precision (8 bytes) floating point number from
/// `self` in big-endian byte order.
///
@@ -870,13 +790,13 @@ pub trait Buf {
/// use std::io::Cursor;
///
/// let mut buf = Cursor::new(b"\x3F\xF3\x33\x33\x33\x33\x33\x33 hello");
- /// assert_eq!(1.2f64, buf.get_f64_be());
+ /// assert_eq!(1.2f64, buf.get_f64());
/// ```
///
/// # Panics
///
/// This function panics if there is not enough remaining data in `self`.
- fn get_f64_be(&mut self) -> f64 {
+ fn get_f64(&mut self) -> f64 {
buf_get_impl!(self, 8, BigEndian::read_f64);
}
@@ -1061,7 +981,7 @@ impl<'a, T: Buf + ?Sized> Buf for &'a mut T {
(**self).bytes()
}
- fn bytes_vec<'b>(&'b self, dst: &mut [&'b IoVec]) -> usize {
+ fn bytes_vec<'b>(&'b self, dst: &mut [IoVec<'b>]) -> usize {
(**self).bytes_vec(dst)
}
@@ -1079,7 +999,7 @@ impl<T: Buf + ?Sized> Buf for Box<T> {
(**self).bytes()
}
- fn bytes_vec<'b>(&'b self, dst: &mut [&'b IoVec]) -> usize {
+ fn bytes_vec<'b>(&'b self, dst: &mut [IoVec<'b>]) -> usize {
(**self).bytes_vec(dst)
}
@@ -1151,4 +1071,4 @@ impl Buf for Option<[u8; 1]> {
// The existance of this function makes the compiler catch if the Buf
// trait is "object-safe" or not.
-fn _assert_trait_object(_b: &Buf) {}
+fn _assert_trait_object(_b: &dyn Buf) {}
diff --git a/src/buf/buf_mut.rs b/src/buf/buf_mut.rs
index 7f3c1f7..29774b9 100644
--- a/src/buf/buf_mut.rs
+++ b/src/buf/buf_mut.rs
@@ -1,6 +1,6 @@
use super::{IntoBuf, Writer};
use byteorder::{LittleEndian, ByteOrder, BigEndian};
-use iovec::IoVec;
+use iovec::IoVecMut;
use std::{cmp, io, ptr, usize};
@@ -189,7 +189,7 @@ pub trait BufMut {
/// with `dst` being a zero length slice.
///
/// [`readv`]: http://man7.org/linux/man-pages/man2/readv.2.html
- unsafe fn bytes_vec_mut<'a>(&'a mut self, dst: &mut [&'a mut IoVec]) -> usize {
+ unsafe fn bytes_vec_mut<'a>(&'a mut self, dst: &mut [IoVecMut<'a>]) -> usize {
if dst.is_empty() {
return 0;
}
@@ -339,14 +339,6 @@ pub trait BufMut {
self.put_slice(&src)
}
- #[doc(hidden)]
- #[deprecated(note="use put_u16_be or put_u16_le")]
- fn put_u16<T: ByteOrder>(&mut self, n: u16) where Self: Sized {
- let mut buf = [0; 2];
- T::write_u16(&mut buf, n);
- self.put_slice(&buf)
- }
-
/// Writes an unsigned 16 bit integer to `self` in big-endian byte order.
///
/// The current position is advanced by 2.
@@ -357,7 +349,7 @@ pub trait BufMut {
/// use bytes::BufMut;
///
/// let mut buf = vec![];
- /// buf.put_u16_be(0x0809);
+ /// buf.put_u16(0x0809);
/// assert_eq!(buf, b"\x08\x09");
/// ```
///
@@ -365,7 +357,7 @@ pub trait BufMut {
///
/// This function panics if there is not enough remaining capacity in
/// `self`.
- fn put_u16_be(&mut self, n: u16) {
+ fn put_u16(&mut self, n: u16) {
let mut buf = [0; 2];
BigEndian::write_u16(&mut buf, n);
self.put_slice(&buf)
@@ -395,14 +387,6 @@ pub trait BufMut {
self.put_slice(&buf)
}
- #[doc(hidden)]
- #[deprecated(note="use put_i16_be or put_i16_le")]
- fn put_i16<T: ByteOrder>(&mut self, n: i16) where Self: Sized {
- let mut buf = [0; 2];
- T::write_i16(&mut buf, n);
- self.put_slice(&buf)
- }
-
/// Writes a signed 16 bit integer to `self` in big-endian byte order.
///
/// The current position is advanced by 2.
@@ -413,7 +397,7 @@ pub trait BufMut {
/// use bytes::BufMut;
///
/// let mut buf = vec![];
- /// buf.put_i16_be(0x0809);
+ /// buf.put_i16(0x0809);
/// assert_eq!(buf, b"\x08\x09");
/// ```
///
@@ -421,7 +405,7 @@ pub trait BufMut {
///
/// This function panics if there is not enough remaining capacity in
/// `self`.
- fn put_i16_be(&mut self, n: i16) {
+ fn put_i16(&mut self, n: i16) {
let mut buf = [0; 2];
BigEndian::write_i16(&mut buf, n);
self.put_slice(&buf)
@@ -451,14 +435,6 @@ pub trait BufMut {
self.put_slice(&buf)
}
- #[doc(hidden)]
- #[deprecated(note="use put_u32_be or put_u32_le")]
- fn put_u32<T: ByteOrder>(&mut self, n: u32) where Self: Sized {
- let mut buf = [0; 4];
- T::write_u32(&mut buf, n);
- self.put_slice(&buf)
- }
-
/// Writes an unsigned 32 bit integer to `self` in big-endian byte order.
///
/// The current position is advanced by 4.
@@ -469,7 +445,7 @@ pub trait BufMut {
/// use bytes::BufMut;
///
/// let mut buf = vec![];
- /// buf.put_u32_be(0x0809A0A1);
+ /// buf.put_u32(0x0809A0A1);
/// assert_eq!(buf, b"\x08\x09\xA0\xA1");
/// ```
///
@@ -477,7 +453,7 @@ pub trait BufMut {
///
/// This function panics if there is not enough remaining capacity in
/// `self`.
- fn put_u32_be(&mut self, n: u32) {
+ fn put_u32(&mut self, n: u32) {
let mut buf = [0; 4];
BigEndian::write_u32(&mut buf, n);
self.put_slice(&buf)
@@ -507,14 +483,6 @@ pub trait BufMut {
self.put_slice(&buf)
}
- #[doc(hidden)]
- #[deprecated(note="use put_i32_be or put_i32_le")]
- fn put_i32<T: ByteOrder>(&mut self, n: i32) where Self: Sized {
- let mut buf = [0; 4];
- T::write_i32(&mut buf, n);
- self.put_slice(&buf)
- }
-
/// Writes a signed 32 bit integer to `self` in big-endian byte order.
///
/// The current position is advanced by 4.
@@ -525,7 +493,7 @@ pub trait BufMut {
/// use bytes::BufMut;
///
/// let mut buf = vec![];
- /// buf.put_i32_be(0x0809A0A1);
+ /// buf.put_i32(0x0809A0A1);
/// assert_eq!(buf, b"\x08\x09\xA0\xA1");
/// ```
///
@@ -533,7 +501,7 @@ pub trait BufMut {
///
/// This function panics if there is not enough remaining capacity in
/// `self`.
- fn put_i32_be(&mut self, n: i32) {
+ fn put_i32(&mut self, n: i32) {
let mut buf = [0; 4];
BigEndian::write_i32(&mut buf, n);
self.put_slice(&buf)
@@ -563,14 +531,6 @@ pub trait BufMut {
self.put_slice(&buf)
}
- #[doc(hidden)]
- #[deprecated(note="use put_u64_be or put_u64_le")]
- fn put_u64<T: ByteOrder>(&mut self, n: u64) where Self: Sized {
- let mut buf = [0; 8];
- T::write_u64(&mut buf, n);
- self.put_slice(&buf)
- }
-
/// Writes an unsigned 64 bit integer to `self` in the big-endian byte order.
///
/// The current position is advanced by 8.
@@ -581,7 +541,7 @@ pub trait BufMut {
/// use bytes::BufMut;
///
/// let mut buf = vec![];
- /// buf.put_u64_be(0x0102030405060708);
+ /// buf.put_u64(0x0102030405060708);
/// assert_eq!(buf, b"\x01\x02\x03\x04\x05\x06\x07\x08");
/// ```
///
@@ -589,7 +549,7 @@ pub trait BufMut {
///
/// This function panics if there is not enough remaining capacity in
/// `self`.
- fn put_u64_be(&mut self, n: u64) {
+ fn put_u64(&mut self, n: u64) {
let mut buf = [0; 8];
BigEndian::write_u64(&mut buf, n);
self.put_slice(&buf)
@@ -619,14 +579,6 @@ pub trait BufMut {
self.put_slice(&buf)
}
- #[doc(hidden)]
- #[deprecated(note="use put_i64_be or put_i64_le")]
- fn put_i64<T: ByteOrder>(&mut self, n: i64) where Self: Sized {
- let mut buf = [0; 8];
- T::write_i64(&mut buf, n);
- self.put_slice(&buf)
- }
-
/// Writes a signed 64 bit integer to `self` in the big-endian byte order.
///
/// The current position is advanced by 8.
@@ -637,7 +589,7 @@ pub trait BufMut {
/// use bytes::BufMut;
///
/// let mut buf = vec![];
- /// buf.put_i64_be(0x0102030405060708);
+ /// buf.put_i64(0x0102030405060708);
/// assert_eq!(buf, b"\x01\x02\x03\x04\x05\x06\x07\x08");
/// ```
///
@@ -645,7 +597,7 @@ pub trait BufMut {
///
/// This function panics if there is not enough remaining capacity in
/// `self`.
- fn put_i64_be(&mut self, n: i64) {
+ fn put_i64(&mut self, n: i64) {
let mut buf = [0; 8];
BigEndian::write_i64(&mut buf, n);
self.put_slice(&buf)
@@ -686,7 +638,7 @@ pub trait BufMut {
/// use bytes::BufMut;
///
/// let mut buf = vec![];
- /// buf.put_u128_be(0x01020304050607080910111213141516);
+ /// buf.put_u128(0x01020304050607080910111213141516);
/// assert_eq!(buf, b"\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10\x11\x12\x13\x14\x15\x16");
/// ```
///
@@ -695,7 +647,7 @@ pub trait BufMut {
/// This function panics if there is not enough remaining capacity in
/// `self`.
#[cfg(feature = "i128")]
- fn put_u128_be(&mut self, n: u128) {
+ fn put_u128(&mut self, n: u128) {
let mut buf = [0; 16];
BigEndian::write_u128(&mut buf, n);
self.put_slice(&buf)
@@ -738,7 +690,7 @@ pub trait BufMut {
/// use bytes::BufMut;
///
/// let mut buf = vec![];
- /// buf.put_i128_be(0x01020304050607080910111213141516);
+ /// buf.put_i128(0x01020304050607080910111213141516);
/// assert_eq!(buf, b"\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10\x11\x12\x13\x14\x15\x16");
/// ```
///
@@ -747,7 +699,7 @@ pub trait BufMut {
/// This function panics if there is not enough remaining capacity in
/// `self`.
#[cfg(feature = "i128")]
- fn put_i128_be(&mut self, n: i128) {
+ fn put_i128(&mut self, n: i128) {
let mut buf = [0; 16];
BigEndian::write_i128(&mut buf, n);
self.put_slice(&buf)
@@ -779,14 +731,6 @@ pub trait BufMut {
self.put_slice(&buf)
}
- #[doc(hidden)]
- #[deprecated(note="use put_uint_be or put_uint_le")]
- fn put_uint<T: ByteOrder>(&mut self, n: u64, nbytes: usize) where Self: Sized {
- let mut buf = [0; 8];
- T::write_uint(&mut buf, n, nbytes);
- self.put_slice(&buf[0..nbytes])
- }
-
/// Writes an unsigned n-byte integer to `self` in big-endian byte order.
///
/// The current position is advanced by `nbytes`.
@@ -797,7 +741,7 @@ pub trait BufMut {
/// use bytes::BufMut;
///
/// let mut buf = vec![];
- /// buf.put_uint_be(0x010203, 3);
+ /// buf.put_uint(0x010203, 3);
/// assert_eq!(buf, b"\x01\x02\x03");
/// ```
///
@@ -805,7 +749,7 @@ pub trait BufMut {
///
/// This function panics if there is not enough remaining capacity in
/// `self`.
- fn put_uint_be(&mut self, n: u64, nbytes: usize) {
+ fn put_uint(&mut self, n: u64, nbytes: usize) {
let mut buf = [0; 8];
BigEndian::write_uint(&mut buf, n, nbytes);
self.put_slice(&buf[0..nbytes])
@@ -835,14 +779,6 @@ pub trait BufMut {
self.put_slice(&buf[0..nbytes])
}
- #[doc(hidden)]
- #[deprecated(note="use put_int_be or put_int_le")]
- fn put_int<T: ByteOrder>(&mut self, n: i64, nbytes: usize) where Self: Sized {
- let mut buf = [0; 8];
- T::write_int(&mut buf, n, nbytes);
- self.put_slice(&buf[0..nbytes])
- }
-
/// Writes a signed n-byte integer to `self` in big-endian byte order.
///
/// The current position is advanced by `nbytes`.
@@ -853,7 +789,7 @@ pub trait BufMut {
/// use bytes::BufMut;
///
/// let mut buf = vec![];
- /// buf.put_int_be(0x010203, 3);
+ /// buf.put_int(0x010203, 3);
/// assert_eq!(buf, b"\x01\x02\x03");
/// ```
///
@@ -861,7 +797,7 @@ pub trait BufMut {
///
/// This function panics if there is not enough remaining capacity in
/// `self`.
- fn put_int_be(&mut self, n: i64, nbytes: usize) {
+ fn put_int(&mut self, n: i64, nbytes: usize) {
let mut buf = [0; 8];
BigEndian::write_int(&mut buf, n, nbytes);
self.put_slice(&buf[0..nbytes])
@@ -891,14 +827,6 @@ pub trait BufMut {
self.put_slice(&buf[0..nbytes])
}
- #[doc(hidden)]
- #[deprecated(note="use put_f32_be or put_f32_le")]
- fn put_f32<T: ByteOrder>(&mut self, n: f32) where Self: Sized {
- let mut buf = [0; 4];
- T::write_f32(&mut buf, n);
- self.put_slice(&buf)
- }
-
/// Writes an IEEE754 single-precision (4 bytes) floating point number to
/// `self` in big-endian byte order.
///
@@ -910,7 +838,7 @@ pub trait BufMut {
/// use bytes::BufMut;
///
/// let mut buf = vec![];
- /// buf.put_f32_be(1.2f32);
+ /// buf.put_f32(1.2f32);
/// assert_eq!(buf, b"\x3F\x99\x99\x9A");
/// ```
///
@@ -918,7 +846,7 @@ pub trait BufMut {
///
/// This function panics if there is not enough remaining capacity in
/// `self`.
- fn put_f32_be(&mut self, n: f32) {
+ fn put_f32(&mut self, n: f32) {
let mut buf = [0; 4];
BigEndian::write_f32(&mut buf, n);
self.put_slice(&buf)
@@ -949,14 +877,6 @@ pub trait BufMut {
self.put_slice(&buf)
}
- #[doc(hidden)]
- #[deprecated(note="use put_f64_be or put_f64_le")]
- fn put_f64<T: ByteOrder>(&mut self, n: f64) where Self: Sized {
- let mut buf = [0; 8];
- T::write_f64(&mut buf, n);
- self.put_slice(&buf)
- }
-
/// Writes an IEEE754 double-precision (8 bytes) floating point number to
/// `self` in big-endian byte order.
///
@@ -968,7 +888,7 @@ pub trait BufMut {
/// use bytes::BufMut;
///
/// let mut buf = vec![];
- /// buf.put_f64_be(1.2f64);
+ /// buf.put_f64(1.2f64);
/// assert_eq!(buf, b"\x3F\xF3\x33\x33\x33\x33\x33\x33");
/// ```
///
@@ -976,7 +896,7 @@ pub trait BufMut {
///
/// This function panics if there is not enough remaining capacity in
/// `self`.
- fn put_f64_be(&mut self, n: f64) {
+ fn put_f64(&mut self, n: f64) {
let mut buf = [0; 8];
BigEndian::write_f64(&mut buf, n);
self.put_slice(&buf)
@@ -1072,7 +992,7 @@ impl<'a, T: BufMut + ?Sized> BufMut for &'a mut T {
(**self).bytes_mut()
}
- unsafe fn bytes_vec_mut<'b>(&'b mut self, dst: &mut [&'b mut IoVec]) -> usize {
+ unsafe fn bytes_vec_mut<'b>(&'b mut self, dst: &mut [IoVecMut<'b>]) -> usize {
(**self).bytes_vec_mut(dst)
}
@@ -1090,7 +1010,7 @@ impl<T: BufMut + ?Sized> BufMut for Box<T> {
(**self).bytes_mut()
}
- unsafe fn bytes_vec_mut<'b>(&'b mut self, dst: &mut [&'b mut IoVec]) -> usize {
+ unsafe fn bytes_vec_mut<'b>(&'b mut self, dst: &mut [IoVecMut<'b>]) -> usize {
(**self).bytes_vec_mut(dst)
}
@@ -1164,4 +1084,4 @@ impl BufMut for Vec<u8> {
// The existance of this function makes the compiler catch if the BufMut
// trait is "object-safe" or not.
-fn _assert_trait_object(_b: &BufMut) {}
+fn _assert_trait_object(_b: &dyn BufMut) {}
diff --git a/src/buf/chain.rs b/src/buf/chain.rs
index 7dd44ab..76f1045 100644
--- a/src/buf/chain.rs
+++ b/src/buf/chain.rs
@@ -1,5 +1,5 @@
use {Buf, BufMut};
-use iovec::IoVec;
+use iovec::{IoVec, IoVecMut};
/// A `Chain` sequences two buffers.
///
@@ -177,7 +177,7 @@ impl<T, U> Buf for Chain<T, U>
self.b.advance(cnt);
}
- fn bytes_vec<'a>(&'a self, dst: &mut [&'a IoVec]) -> usize {
+ fn bytes_vec<'a>(&'a self, dst: &mut [IoVec<'a>]) -> usize {
let mut n = self.a.bytes_vec(dst);
n += self.b.bytes_vec(&mut dst[n..]);
n
@@ -218,7 +218,7 @@ impl<T, U> BufMut for Chain<T, U>
self.b.advance_mut(cnt);
}
- unsafe fn bytes_vec_mut<'a>(&'a mut self, dst: &mut [&'a mut IoVec]) -> usize {
+ unsafe fn bytes_vec_mut<'a>(&'a mut self, dst: &mut [IoVecMut<'a>]) -> usize {
let mut n = self.a.bytes_vec_mut(dst);
n += self.b.bytes_vec_mut(&mut dst[n..]);
n
diff --git a/src/buf/into_buf.rs b/src/buf/into_buf.rs
index 4c3b420..d43f95b 100644
--- a/src/buf/into_buf.rs
+++ b/src/buf/into_buf.rs
@@ -11,12 +11,12 @@ use std::io;
/// # Examples
///
/// ```
-/// use bytes::{Buf, IntoBuf, BigEndian};
+/// use bytes::{Buf, IntoBuf};
///
/// let bytes = b"\x00\x01hello world";
/// let mut buf = bytes.into_buf();
///
-/// assert_eq!(1, buf.get_u16::<BigEndian>());
+/// assert_eq!(1, buf.get_u16());
///
/// let mut rest = [0; 11];
/// buf.copy_to_slice(&mut rest);
@@ -32,12 +32,12 @@ pub trait IntoBuf {
/// # Examples
///
/// ```
- /// use bytes::{Buf, IntoBuf, BigEndian};
+ /// use bytes::{Buf, IntoBuf};
///
/// let bytes = b"\x00\x01hello world";
/// let mut buf = bytes.into_buf();
///
- /// assert_eq!(1, buf.get_u16::<BigEndian>());
+ /// assert_eq!(1, buf.get_u16());
///
/// let mut rest = [0; 11];
/// buf.copy_to_slice(&mut rest);