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

Implementations

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));

Read up to and including the supplied nibble.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.