pub trait FromByteswhere
Self: Sized,{
// Required method
fn from_bytes<TB: TakeBytes>(source: &mut TB) -> Result<Self, Error>;
}
Expand description
Trait that supports reading datatypes from a binary data stream.
Datatypes that implements this trait can be read from a binary data stream.
Required Methods§
Sourcefn from_bytes<TB: TakeBytes>(source: &mut TB) -> Result<Self, Error>
fn from_bytes<TB: TakeBytes>(source: &mut TB) -> Result<Self, Error>
Reads data from the given source
.
Reads as much as necessary from source
. The method deserializes the
instance and returns it.
§Errors
If not enough data are available in source
, the
TakeBytes::take_bytes()
call returns a
TakeBytesError::Eof
error, which should be simply forwarded.
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.