Trait binrw::prelude::BinRead[][src]

pub trait BinRead: Sized + 'static {
    type Args: Clone;
    fn read_options<R: Read + Seek>(
        reader: &mut R,
        options: &ReadOptions,
        args: Self::Args
    ) -> BinResult<Self>; fn read<R: Read + Seek>(reader: &mut R) -> BinResult<Self>
    where
        Self::Args: Default
, { ... }
fn read_args<R: Read + Seek>(
        reader: &mut R,
        args: Self::Args
    ) -> BinResult<Self> { ... }
fn after_parse<R: Read + Seek>(
        &mut self,
        _: &mut R,
        _: &ReadOptions,
        _: Self::Args
    ) -> BinResult<()> { ... } }
Expand description

The BinRead trait reads data from streams and converts it into objects.

This trait is usually derived, but can also be manually implemented by writing an appropriate Args type and read_options() function.

Derivable

This trait can be used with #[derive] or #[derive_binread]. Each field of a derived type must either implement BinRead or be annotated with an attribute containing a map, try_map, or parse_with directive.

Using #[derive_binread] instead of #[derive] is required when using temporary fields.

Associated Types

The type used for the args parameter of read_args() and read_options().

When the given type implements Default, convenience functions like read() are enabled. BinRead implementations that don’t receive any arguments should use the () type.

When BinRead is derived, the import and import_tuple directives define this type.

Required methods

Read Self from the reader using the given ReadOptions and arguments.

Provided methods

Read Self from the reader using default arguments.

Read Self from the reader using the given arguments.

Runs any post-processing steps required to finalize construction of the object.

Implementations on Foreign Types

Implementors