From ea9fbbc614586a4815a798009452f80da1f130a6 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Sat, 4 Mar 2017 13:19:17 -0800 Subject: Add 'Errors' headers. Fixes #72 --- src/new.rs | 138 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+) (limited to 'src') diff --git a/src/new.rs b/src/new.rs index c1df717..79ef5fd 100644 --- a/src/new.rs +++ b/src/new.rs @@ -25,6 +25,12 @@ pub trait ReadBytesExt: io::Read { /// /// Note that since this reads a single byte, no byte order conversions /// are used. It is included for completeness. + /// + /// # Errors + /// + /// This method returns the same errors as [`Read::read_exact`]. + /// + /// [`Read::read_exact`]: https://doc.rust-lang.org/std/io/trait.Read.html#method.read_exact #[inline] fn read_u8(&mut self) -> Result { let mut buf = [0; 1]; @@ -36,6 +42,12 @@ pub trait ReadBytesExt: io::Read { /// /// Note that since this reads a single byte, no byte order conversions /// are used. It is included for completeness. + /// + /// # Errors + /// + /// This method returns the same errors as [`Read::read_exact`]. + /// + /// [`Read::read_exact`]: https://doc.rust-lang.org/std/io/trait.Read.html#method.read_exact #[inline] fn read_i8(&mut self) -> Result { let mut buf = [0; 1]; @@ -44,6 +56,12 @@ pub trait ReadBytesExt: io::Read { } /// Reads an unsigned 16 bit integer from the underlying reader. + /// + /// # Errors + /// + /// This method returns the same errors as [`Read::read_exact`]. + /// + /// [`Read::read_exact`]: https://doc.rust-lang.org/std/io/trait.Read.html#method.read_exact #[inline] fn read_u16(&mut self) -> Result { let mut buf = [0; 2]; @@ -52,6 +70,12 @@ pub trait ReadBytesExt: io::Read { } /// Reads a signed 16 bit integer from the underlying reader. + /// + /// # Errors + /// + /// This method returns the same errors as [`Read::read_exact`]. + /// + /// [`Read::read_exact`]: https://doc.rust-lang.org/std/io/trait.Read.html#method.read_exact #[inline] fn read_i16(&mut self) -> Result { let mut buf = [0; 2]; @@ -60,6 +84,12 @@ pub trait ReadBytesExt: io::Read { } /// Reads an unsigned 32 bit integer from the underlying reader. + /// + /// # Errors + /// + /// This method returns the same errors as [`Read::read_exact`]. + /// + /// [`Read::read_exact`]: https://doc.rust-lang.org/std/io/trait.Read.html#method.read_exact #[inline] fn read_u32(&mut self) -> Result { let mut buf = [0; 4]; @@ -68,6 +98,12 @@ pub trait ReadBytesExt: io::Read { } /// Reads a signed 32 bit integer from the underlying reader. + /// + /// # Errors + /// + /// This method returns the same errors as [`Read::read_exact`]. + /// + /// [`Read::read_exact`]: https://doc.rust-lang.org/std/io/trait.Read.html#method.read_exact #[inline] fn read_i32(&mut self) -> Result { let mut buf = [0; 4]; @@ -76,6 +112,12 @@ pub trait ReadBytesExt: io::Read { } /// Reads an unsigned 64 bit integer from the underlying reader. + /// + /// # Errors + /// + /// This method returns the same errors as [`Read::read_exact`]. + /// + /// [`Read::read_exact`]: https://doc.rust-lang.org/std/io/trait.Read.html#method.read_exact #[inline] fn read_u64(&mut self) -> Result { let mut buf = [0; 8]; @@ -84,6 +126,12 @@ pub trait ReadBytesExt: io::Read { } /// Reads a signed 64 bit integer from the underlying reader. + /// + /// # Errors + /// + /// This method returns the same errors as [`Read::read_exact`]. + /// + /// [`Read::read_exact`]: https://doc.rust-lang.org/std/io/trait.Read.html#method.read_exact #[inline] fn read_i64(&mut self) -> Result { let mut buf = [0; 8]; @@ -92,6 +140,12 @@ pub trait ReadBytesExt: io::Read { } /// Reads an unsigned n-bytes integer from the underlying reader. + /// + /// # Errors + /// + /// This method returns the same errors as [`Read::read_exact`]. + /// + /// [`Read::read_exact`]: https://doc.rust-lang.org/std/io/trait.Read.html#method.read_exact #[inline] fn read_uint(&mut self, nbytes: usize) -> Result { let mut buf = [0; 8]; @@ -100,6 +154,12 @@ pub trait ReadBytesExt: io::Read { } /// Reads a signed n-bytes integer from the underlying reader. + /// + /// # Errors + /// + /// This method returns the same errors as [`Read::read_exact`]. + /// + /// [`Read::read_exact`]: https://doc.rust-lang.org/std/io/trait.Read.html#method.read_exact #[inline] fn read_int(&mut self, nbytes: usize) -> Result { let mut buf = [0; 8]; @@ -109,6 +169,12 @@ pub trait ReadBytesExt: io::Read { /// Reads a IEEE754 single-precision (4 bytes) floating point number from /// the underlying reader. + /// + /// # Errors + /// + /// This method returns the same errors as [`Read::read_exact`]. + /// + /// [`Read::read_exact`]: https://doc.rust-lang.org/std/io/trait.Read.html#method.read_exact #[inline] fn read_f32(&mut self) -> Result { let mut buf = [0; 4]; @@ -119,6 +185,12 @@ pub trait ReadBytesExt: io::Read { /// Reads a IEEE754 double-precision (8 bytes) floating point number from /// the underlying reader. #[inline] + /// + /// # Errors + /// + /// This method returns the same errors as [`Read::read_exact`]. + /// + /// [`Read::read_exact`]: https://doc.rust-lang.org/std/io/trait.Read.html#method.read_exact fn read_f64(&mut self) -> Result { let mut buf = [0; 8]; try!(self.read_exact(&mut buf)); @@ -153,6 +225,12 @@ pub trait WriteBytesExt: io::Write { /// /// Note that since this writes a single byte, no byte order conversions /// are used. It is included for completeness. + /// + /// # Errors + /// + /// This method returns the same errors as [`Write::write_all`]. + /// + /// [`Write::write_all`]: https://doc.rust-lang.org/std/io/trait.Write.html#method.write_all #[inline] fn write_u8(&mut self, n: u8) -> Result<()> { self.write_all(&[n]) @@ -162,12 +240,24 @@ pub trait WriteBytesExt: io::Write { /// /// Note that since this writes a single byte, no byte order conversions /// are used. It is included for completeness. + /// + /// # Errors + /// + /// This method returns the same errors as [`Write::write_all`]. + /// + /// [`Write::write_all`]: https://doc.rust-lang.org/std/io/trait.Write.html#method.write_all #[inline] fn write_i8(&mut self, n: i8) -> Result<()> { self.write_all(&[n as u8]) } /// Writes an unsigned 16 bit integer to the underlying writer. + /// + /// # Errors + /// + /// This method returns the same errors as [`Write::write_all`]. + /// + /// [`Write::write_all`]: https://doc.rust-lang.org/std/io/trait.Write.html#method.write_all #[inline] fn write_u16(&mut self, n: u16) -> Result<()> { let mut buf = [0; 2]; @@ -176,6 +266,12 @@ pub trait WriteBytesExt: io::Write { } /// Writes a signed 16 bit integer to the underlying writer. + /// + /// # Errors + /// + /// This method returns the same errors as [`Write::write_all`]. + /// + /// [`Write::write_all`]: https://doc.rust-lang.org/std/io/trait.Write.html#method.write_all #[inline] fn write_i16(&mut self, n: i16) -> Result<()> { let mut buf = [0; 2]; @@ -184,6 +280,12 @@ pub trait WriteBytesExt: io::Write { } /// Writes an unsigned 32 bit integer to the underlying writer. + /// + /// # Errors + /// + /// This method returns the same errors as [`Write::write_all`]. + /// + /// [`Write::write_all`]: https://doc.rust-lang.org/std/io/trait.Write.html#method.write_all #[inline] fn write_u32(&mut self, n: u32) -> Result<()> { let mut buf = [0; 4]; @@ -192,6 +294,12 @@ pub trait WriteBytesExt: io::Write { } /// Writes a signed 32 bit integer to the underlying writer. + /// + /// # Errors + /// + /// This method returns the same errors as [`Write::write_all`]. + /// + /// [`Write::write_all`]: https://doc.rust-lang.org/std/io/trait.Write.html#method.write_all #[inline] fn write_i32(&mut self, n: i32) -> Result<()> { let mut buf = [0; 4]; @@ -200,6 +308,12 @@ pub trait WriteBytesExt: io::Write { } /// Writes an unsigned 64 bit integer to the underlying writer. + /// + /// # Errors + /// + /// This method returns the same errors as [`Write::write_all`]. + /// + /// [`Write::write_all`]: https://doc.rust-lang.org/std/io/trait.Write.html#method.write_all #[inline] fn write_u64(&mut self, n: u64) -> Result<()> { let mut buf = [0; 8]; @@ -208,6 +322,12 @@ pub trait WriteBytesExt: io::Write { } /// Writes a signed 64 bit integer to the underlying writer. + /// + /// # Errors + /// + /// This method returns the same errors as [`Write::write_all`]. + /// + /// [`Write::write_all`]: https://doc.rust-lang.org/std/io/trait.Write.html#method.write_all #[inline] fn write_i64(&mut self, n: i64) -> Result<()> { let mut buf = [0; 8]; @@ -217,6 +337,12 @@ pub trait WriteBytesExt: io::Write { /// Writes an unsigned n-bytes integer to the underlying writer. /// + /// # Errors + /// + /// This method returns the same errors as [`Write::write_all`]. + /// + /// [`Write::write_all`]: https://doc.rust-lang.org/std/io/trait.Write.html#method.write_all + /// /// # Panics /// /// If the given integer is not representable in the given number of bytes, @@ -234,6 +360,12 @@ pub trait WriteBytesExt: io::Write { /// Writes a signed n-bytes integer to the underlying writer. /// + /// # Errors + /// + /// This method returns the same errors as [`Write::write_all`]. + /// + /// [`Write::write_all`]: https://doc.rust-lang.org/std/io/trait.Write.html#method.write_all + /// /// # Panics /// /// If the given integer is not representable in the given number of bytes, @@ -251,6 +383,12 @@ pub trait WriteBytesExt: io::Write { /// Writes a IEEE754 single-precision (4 bytes) floating point number to /// the underlying writer. + /// + /// # Errors + /// + /// This method returns the same errors as [`Write::write_all`]. + /// + /// [`Write::write_all`]: https://doc.rust-lang.org/std/io/trait.Write.html#method.write_all #[inline] fn write_f32(&mut self, n: f32) -> Result<()> { let mut buf = [0; 4]; -- cgit v1.2.3