Trait ReadBytesExt
pub trait ReadBytesExt: Read
Extends Read with methods for reading numbers. (For std::io.)
Most of the methods defined here have an unconstrained type parameter that
must be explicitly instantiated. Typically, it is instantiated with either
the BigEndian or LittleEndian types defined in this crate.
Examples
Read unsigned 16 bit big-endian integers from a Read:
use Cursor;
use ;
let mut rdr = new;
assert_eq!;
assert_eq!;
Provided Methods
fn read_u8(&mut self) -> Result<u8>Reads an unsigned 8 bit integer from the underlying reader.
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.Examples
Read unsigned 8 bit integers from a
Read:use Cursor; use ReadBytesExt; let mut rdr = new; assert_eq!; assert_eq!;fn read_i8(&mut self) -> Result<i8>Reads a signed 8 bit integer from the underlying reader.
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.Examples
Read signed 8 bit integers from a
Read:use Cursor; use ReadBytesExt; let mut rdr = new; assert_eq!; assert_eq!;fn read_u16<T: ByteOrder>(&mut self) -> Result<u16>Reads an unsigned 16 bit integer from the underlying reader.
Errors
This method returns the same errors as
Read::read_exact.Examples
Read unsigned 16 bit big-endian integers from a
Read:use Cursor; use ; let mut rdr = new; assert_eq!; assert_eq!;fn read_i16<T: ByteOrder>(&mut self) -> Result<i16>Reads a signed 16 bit integer from the underlying reader.
Errors
This method returns the same errors as
Read::read_exact.Examples
Read signed 16 bit big-endian integers from a
Read:use Cursor; use ; let mut rdr = new; assert_eq!; assert_eq!;fn read_u24<T: ByteOrder>(&mut self) -> Result<u32>Reads an unsigned 24 bit integer from the underlying reader.
Errors
This method returns the same errors as
Read::read_exact.Examples
Read unsigned 24 bit big-endian integers from a
Read:use Cursor; use ; let mut rdr = new; assert_eq!;fn read_i24<T: ByteOrder>(&mut self) -> Result<i32>Reads a signed 24 bit integer from the underlying reader.
Errors
This method returns the same errors as
Read::read_exact.Examples
Read signed 24 bit big-endian integers from a
Read:use Cursor; use ; let mut rdr = new; assert_eq!;fn read_u32<T: ByteOrder>(&mut self) -> Result<u32>Reads an unsigned 32 bit integer from the underlying reader.
Errors
This method returns the same errors as
Read::read_exact.Examples
Read unsigned 32 bit big-endian integers from a
Read:use Cursor; use ; let mut rdr = new; assert_eq!;fn read_i32<T: ByteOrder>(&mut self) -> Result<i32>Reads a signed 32 bit integer from the underlying reader.
Errors
This method returns the same errors as
Read::read_exact.Examples
Read signed 32 bit big-endian integers from a
Read:use Cursor; use ; let mut rdr = new; assert_eq!;fn read_u48<T: ByteOrder>(&mut self) -> Result<u64>Reads an unsigned 48 bit integer from the underlying reader.
Errors
This method returns the same errors as
Read::read_exact.Examples
Read unsigned 48 bit big-endian integers from a
Read:use Cursor; use ; let mut rdr = new; assert_eq!;fn read_i48<T: ByteOrder>(&mut self) -> Result<i64>Reads a signed 48 bit integer from the underlying reader.
Errors
This method returns the same errors as
Read::read_exact.Examples
Read signed 48 bit big-endian integers from a
Read:use Cursor; use ; let mut rdr = new; assert_eq!;fn read_u64<T: ByteOrder>(&mut self) -> Result<u64>Reads an unsigned 64 bit integer from the underlying reader.
Errors
This method returns the same errors as
Read::read_exact.Examples
Read an unsigned 64 bit big-endian integer from a
Read:use Cursor; use ; let mut rdr = new; assert_eq!;fn read_i64<T: ByteOrder>(&mut self) -> Result<i64>Reads a signed 64 bit integer from the underlying reader.
Errors
This method returns the same errors as
Read::read_exact.Examples
Read a signed 64 bit big-endian integer from a
Read:use Cursor; use ; let mut rdr = new; assert_eq!;fn read_u128<T: ByteOrder>(&mut self) -> Result<u128>Reads an unsigned 128 bit integer from the underlying reader.
Errors
This method returns the same errors as
Read::read_exact.Examples
Read an unsigned 128 bit big-endian integer from a
Read:use Cursor; use ; let mut rdr = new; assert_eq!;fn read_i128<T: ByteOrder>(&mut self) -> Result<i128>Reads a signed 128 bit integer from the underlying reader.
Errors
This method returns the same errors as
Read::read_exact.Examples
Read a signed 128 bit big-endian integer from a
Read:use Cursor; use ; let mut rdr = new; assert_eq!;fn read_uint<T: ByteOrder>(&mut self, nbytes: usize) -> Result<u64>Reads an unsigned n-bytes integer from the underlying reader.
Errors
This method returns the same errors as
Read::read_exact.Examples
Read an unsigned n-byte big-endian integer from a
Read:use Cursor; use ; let mut rdr = new; assert_eq!;fn read_int<T: ByteOrder>(&mut self, nbytes: usize) -> Result<i64>Reads a signed n-bytes integer from the underlying reader.
Errors
This method returns the same errors as
Read::read_exact.Examples
Read an unsigned n-byte big-endian integer from a
Read:use Cursor; use ; let mut rdr = new; assert_eq!;fn read_uint128<T: ByteOrder>(&mut self, nbytes: usize) -> Result<u128>Reads an unsigned n-bytes integer from the underlying reader.
fn read_int128<T: ByteOrder>(&mut self, nbytes: usize) -> Result<i128>Reads a signed n-bytes integer from the underlying reader.
fn read_f32<T: ByteOrder>(&mut self) -> Result<f32>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.Examples
Read a big-endian single-precision floating point number from a
Read:use f32; use Cursor; use ; let mut rdr = new; assert_eq!;fn read_f64<T: ByteOrder>(&mut self) -> Result<f64>Reads a IEEE754 double-precision (8 bytes) floating point number from the underlying reader.
Errors
This method returns the same errors as
Read::read_exact.Examples
Read a big-endian double-precision floating point number from a
Read:use f64; use Cursor; use ; let mut rdr = new; assert_eq!;
Implementors
impl<R: Read + ?Sized> ReadBytesExt for R