[][src]Trait bitstream_io::read::ByteRead

pub trait ByteRead {
    pub fn read<N: Numeric>(&mut self) -> Result<N, Error>;

    pub fn read_bytes(&mut self, buf: &mut [u8]) -> Result<()> { ... }
}

A trait for anything that can read aligned values from an input stream

Required methods

pub fn read<N: Numeric>(&mut self) -> Result<N, Error>[src]

Reads whole numeric value from stream

Errors

Passes along any I/O error from the underlying stream.

Examples

use std::io::{Read, Cursor};
use bitstream_io::{BigEndian, ByteReader, ByteRead};
let data = [0b00000000, 0b11111111];
let mut reader = ByteReader::endian(Cursor::new(&data), BigEndian);
assert_eq!(reader.read::<u16>().unwrap(), 0b0000000011111111);
use std::io::{Read, Cursor};
use bitstream_io::{LittleEndian, ByteReader, ByteRead};
let data = [0b00000000, 0b11111111];
let mut reader = ByteReader::endian(Cursor::new(&data), LittleEndian);
assert_eq!(reader.read::<u16>().unwrap(), 0b1111111100000000);
Loading content...

Provided methods

pub fn read_bytes(&mut self, buf: &mut [u8]) -> Result<()>[src]

Completely fills the given buffer with whole bytes.

Errors

Passes along any I/O error from the underlying stream.

Loading content...

Implementors

impl<R: Read, E: Endianness> ByteRead for ByteReader<R, E>[src]

Loading content...