pub trait BinRead: Sized {
type Args: Any + Copy;
// Required method
fn read_options<R>(
reader: &mut R,
options: &ReadOptions,
args: Self::Args,
) -> Result<Self, Error>
where R: Read + Seek;
// Provided methods
fn read<R>(reader: &mut R) -> Result<Self, Error>
where R: Read + Seek { ... }
fn read_args<R>(reader: &mut R, args: Self::Args) -> Result<Self, Error>
where R: Read + Seek { ... }
fn after_parse<R>(
&mut self,
_: &mut R,
_: &ReadOptions,
_: Self::Args,
) -> Result<(), Error>
where R: Read + Seek { ... }
fn args_default() -> Option<Self::Args> { ... }
}Expand description
Required Associated Types§
Required Methods§
Sourcefn read_options<R>(
reader: &mut R,
options: &ReadOptions,
args: Self::Args,
) -> Result<Self, Error>
fn read_options<R>( reader: &mut R, options: &ReadOptions, args: Self::Args, ) -> Result<Self, Error>
Read the type from the reader
Provided Methods§
Sourcefn read<R>(reader: &mut R) -> Result<Self, Error>
fn read<R>(reader: &mut R) -> Result<Self, Error>
Read the type from the reader while assuming no arguments have been passed
§Panics
Panics if there is no args_default implementation
Sourcefn read_args<R>(reader: &mut R, args: Self::Args) -> Result<Self, Error>
fn read_args<R>(reader: &mut R, args: Self::Args) -> Result<Self, Error>
Read the type from the reader using the specified arguments
fn after_parse<R>( &mut self, _: &mut R, _: &ReadOptions, _: Self::Args, ) -> Result<(), Error>
Sourcefn args_default() -> Option<Self::Args>
fn args_default() -> Option<Self::Args>
The default arguments to be used when using the read shortcut method.
Override this for any type that optionally requries arguments
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl<C, B> BinRead for Vec<B>
impl<C, B> BinRead for Vec<B>
Source§impl<C, B, const N: usize> BinRead for [B; N]
Available on crate feature const_generics only.
impl<C, B, const N: usize> BinRead for [B; N]
Available on crate feature
const_generics only.