pub trait Read: Sized {
type Cfg: Clone + Send + 'static;
// Required method
fn read_cfg(buf: &mut impl Buf, cfg: &Self::Cfg) -> Result<Self, Error>;
}
Expand description
Trait for types that can be read (decoded) from a byte buffer.
Required Associated Types§
Required Methods§
Sourcefn read_cfg(buf: &mut impl Buf, cfg: &Self::Cfg) -> Result<Self, Error>
fn read_cfg(buf: &mut impl Buf, cfg: &Self::Cfg) -> Result<Self, Error>
Reads a value from the buffer using the provided configuration cfg
.
Implementations should consume the exact number of bytes required from buf
to reconstruct
the value.
Returns Error
if decoding fails due to invalid data, insufficient bytes in the buffer,
or violation of constraints imposed by the cfg
.
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.