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
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.