pub trait BinRead: Sized {
type Args: Any + Copy;
// Required method
fn read_options<R: Read + Seek>(
reader: &mut R,
options: &ReadOptions,
args: Self::Args,
) -> BinResult<Self>;
// Provided methods
fn read<R: Read + Seek>(reader: &mut R) -> BinResult<Self> { ... }
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<()> { ... }
fn args_default() -> Option<Self::Args> { ... }
}
Expand description
Required Associated Types§
Required Methods§
sourcefn read_options<R: Read + Seek>(
reader: &mut R,
options: &ReadOptions,
args: Self::Args,
) -> BinResult<Self>
fn read_options<R: Read + Seek>( reader: &mut R, options: &ReadOptions, args: Self::Args, ) -> BinResult<Self>
Read the type from the reader
Provided Methods§
sourcefn read<R: Read + Seek>(reader: &mut R) -> BinResult<Self>
fn read<R: Read + Seek>(reader: &mut R) -> BinResult<Self>
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: Read + Seek>(
reader: &mut R,
args: Self::Args,
) -> BinResult<Self>
fn read_args<R: Read + Seek>( reader: &mut R, args: Self::Args, ) -> BinResult<Self>
Read the type from the reader using the specified arguments
fn after_parse<R: Read + Seek>( &mut self, _: &mut R, _: &ReadOptions, _: Self::Args, ) -> BinResult<()>
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
Object Safety§
This trait is not object safe.