diff options
author | Brian Anderson <banderson@mozilla.com> | 2017-03-03 20:46:35 -0800 |
---|---|---|
committer | Andrew Gallant <jamslam@gmail.com> | 2017-03-28 11:53:06 -0400 |
commit | 08561130c567b442ecbc7d1e6a744df723f2c708 (patch) | |
tree | e179b8bf47f7b0dd9d883a1741a0508bc82016b6 | |
parent | 6eb15de77602d7700a07444d5a732bec6c7241b9 (diff) | |
download | byteorder-08561130c567b442ecbc7d1e6a744df723f2c708.tar.gz |
Add 'Panics' headers. Fixes #72
-rw-r--r-- | src/lib.rs | 40 | ||||
-rw-r--r-- | src/new.rs | 4 |
2 files changed, 44 insertions, 0 deletions
@@ -120,48 +120,66 @@ pub trait ByteOrder : Clone + Copy + Debug + Default + Eq + Hash + Ord + PartialEq + PartialOrd { /// Reads an unsigned 16 bit integer from `buf`. /// + /// # Panics + /// /// Panics when `buf.len() < 2`. fn read_u16(buf: &[u8]) -> u16; /// Reads an unsigned 32 bit integer from `buf`. /// + /// # Panics + /// /// Panics when `buf.len() < 4`. fn read_u32(buf: &[u8]) -> u32; /// Reads an unsigned 64 bit integer from `buf`. /// + /// # Panics + /// /// Panics when `buf.len() < 8`. fn read_u64(buf: &[u8]) -> u64; /// Reads an unsigned n-bytes integer from `buf`. /// + /// # Panics + /// /// Panics when `nbytes < 1` or `nbytes > 8` or /// `buf.len() < nbytes` fn read_uint(buf: &[u8], nbytes: usize) -> u64; /// Writes an unsigned 16 bit integer `n` to `buf`. /// + /// # Panics + /// /// Panics when `buf.len() < 2`. fn write_u16(buf: &mut [u8], n: u16); /// Writes an unsigned 32 bit integer `n` to `buf`. /// + /// # Panics + /// /// Panics when `buf.len() < 4`. fn write_u32(buf: &mut [u8], n: u32); /// Writes an unsigned 64 bit integer `n` to `buf`. /// + /// # Panics + /// /// Panics when `buf.len() < 8`. fn write_u64(buf: &mut [u8], n: u64); /// Writes an unsigned integer `n` to `buf` using only `nbytes`. /// + /// # Panics + /// /// If `n` is not representable in `nbytes`, or if `nbytes` is `> 8`, then /// this method panics. fn write_uint(buf: &mut [u8], n: u64, nbytes: usize); /// Reads a signed 16 bit integer from `buf`. /// + /// # Panics + /// /// Panics when `buf.len() < 2`. #[inline] fn read_i16(buf: &[u8]) -> i16 { @@ -170,6 +188,8 @@ pub trait ByteOrder /// Reads a signed 32 bit integer from `buf`. /// + /// # Panics + /// /// Panics when `buf.len() < 4`. #[inline] fn read_i32(buf: &[u8]) -> i32 { @@ -178,6 +198,8 @@ pub trait ByteOrder /// Reads a signed 64 bit integer from `buf`. /// + /// # Panics + /// /// Panics when `buf.len() < 8`. #[inline] fn read_i64(buf: &[u8]) -> i64 { @@ -186,6 +208,8 @@ pub trait ByteOrder /// Reads a signed n-bytes integer from `buf`. /// + /// # Panics + /// /// Panics when `nbytes < 1` or `nbytes > 8` or /// `buf.len() < nbytes` #[inline] @@ -195,6 +219,8 @@ pub trait ByteOrder /// Reads a IEEE754 single-precision (4 bytes) floating point number. /// + /// # Panics + /// /// Panics when `buf.len() < 4`. #[inline] fn read_f32(buf: &[u8]) -> f32 { @@ -203,6 +229,8 @@ pub trait ByteOrder /// Reads a IEEE754 double-precision (8 bytes) floating point number. /// + /// # Panics + /// /// Panics when `buf.len() < 8`. #[inline] fn read_f64(buf: &[u8]) -> f64 { @@ -211,6 +239,8 @@ pub trait ByteOrder /// Writes a signed 16 bit integer `n` to `buf`. /// + /// # Panics + /// /// Panics when `buf.len() < 2`. #[inline] fn write_i16(buf: &mut [u8], n: i16) { @@ -219,6 +249,8 @@ pub trait ByteOrder /// Writes a signed 32 bit integer `n` to `buf`. /// + /// # Panics + /// /// Panics when `buf.len() < 4`. #[inline] fn write_i32(buf: &mut [u8], n: i32) { @@ -227,6 +259,8 @@ pub trait ByteOrder /// Writes a signed 64 bit integer `n` to `buf`. /// + /// # Panics + /// /// Panics when `buf.len() < 8`. #[inline] fn write_i64(buf: &mut [u8], n: i64) { @@ -235,6 +269,8 @@ pub trait ByteOrder /// Writes a signed integer `n` to `buf` using only `nbytes`. /// + /// # Panics + /// /// If `n` is not representable in `nbytes`, or if `nbytes` is `> 8`, then /// this method panics. #[inline] @@ -244,6 +280,8 @@ pub trait ByteOrder /// Writes a IEEE754 single-precision (4 bytes) floating point number. /// + /// # Panics + /// /// Panics when `buf.len() < 4`. #[inline] fn write_f32(buf: &mut [u8], n: f32) { @@ -252,6 +290,8 @@ pub trait ByteOrder /// Writes a IEEE754 double-precision (8 bytes) floating point number. /// + /// # Panics + /// /// Panics when `buf.len() < 8`. #[inline] fn write_f64(buf: &mut [u8], n: f64) { @@ -217,6 +217,8 @@ pub trait WriteBytesExt: io::Write { /// Writes an unsigned n-bytes integer to the underlying writer. /// + /// # Panics + /// /// If the given integer is not representable in the given number of bytes, /// this method panics. If `nbytes > 8`, this method panics. #[inline] @@ -232,6 +234,8 @@ pub trait WriteBytesExt: io::Write { /// Writes a signed n-bytes integer to the underlying writer. /// + /// # Panics + /// /// If the given integer is not representable in the given number of bytes, /// this method panics. If `nbytes > 8`, this method panics. #[inline] |