Struct allsorts_no_std::binary::read::ReadCtxt[][src]

pub struct ReadCtxt<'a> { /* fields omitted */ }

Implementations

impl<'a> ReadCtxt<'a>[src]

pub fn check(&self, cond: bool) -> Result<(), ParseError>[src]

pub fn check_version(&self, cond: bool) -> Result<(), ParseError>[src]

Check a condition, returning ParseError::BadVersion if false.

Intended for use in checking versions read from data. Example:

use allsorts::binary::read::ReadScope;
use allsorts::error::ParseError;

let scope = ReadScope::new(&[0, 2]);
let mut ctxt = scope.ctxt();
let major_version = ctxt.read_u16be().expect("unable to read version");

assert!(ctxt.check_version(major_version == 2).is_ok());
assert_eq!(ctxt.check_version(major_version == 1), Err(ParseError::BadVersion));

pub fn scope(&self) -> ReadScope<'a>[src]

pub fn read<T: ReadBinaryDep<'a, Args = ()>>(
    &mut self
) -> Result<T::HostType, ParseError>
[src]

pub fn read_dep<T: ReadBinaryDep<'a>>(
    &mut self,
    args: T::Args
) -> Result<T::HostType, ParseError>
[src]

pub fn bytes_available(&self) -> bool[src]

pub fn read_u8(&mut self) -> Result<u8, ReadEof>[src]

pub fn read_i8(&mut self) -> Result<i8, ReadEof>[src]

pub fn read_u16be(&mut self) -> Result<u16, ReadEof>[src]

pub fn read_i16be(&mut self) -> Result<i16, ReadEof>[src]

pub fn read_u32be(&mut self) -> Result<u32, ReadEof>[src]

pub fn read_i32be(&mut self) -> Result<i32, ReadEof>[src]

pub fn read_u64be(&mut self) -> Result<u64, ReadEof>[src]

pub fn read_i64be(&mut self) -> Result<i64, ReadEof>[src]

pub fn read_array<T: ReadUnchecked<'a>>(
    &mut self,
    length: usize
) -> Result<ReadArray<'a, T>, ParseError>
[src]

pub fn read_array_upto_hack<T: ReadUnchecked<'a>>(
    &mut self,
    length: usize
) -> Result<ReadArray<'a, T>, ParseError>
[src]

pub fn read_until_nibble(&mut self, nibble: u8) -> Result<&'a [u8], ReadEof>[src]

Read up to and including the supplied nibble.

pub fn read_array_dep<T: ReadFixedSizeDep<'a>>(
    &mut self,
    length: usize,
    args: T::Args
) -> Result<ReadArray<'a, T>, ParseError>
[src]

pub fn read_scope(&mut self, length: usize) -> Result<ReadScope<'a>, ReadEof>[src]

pub fn read_slice(&mut self, length: usize) -> Result<&'a [u8], ReadEof>[src]

Trait Implementations

impl<'a> Clone for ReadCtxt<'a>[src]

Auto Trait Implementations

impl<'a> RefUnwindSafe for ReadCtxt<'a>

impl<'a> Send for ReadCtxt<'a>

impl<'a> Sync for ReadCtxt<'a>

impl<'a> Unpin for ReadCtxt<'a>

impl<'a> UnwindSafe for ReadCtxt<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.