pub trait Decode: Sized {
// Required method
fn decode<R: Read>(r: R) -> Result<Self, Error>;
}Expand description
A trait that can be decoded from an io::Read stream.
Implementing this trait allows types to be decoded from an io::Read stream,
which is useful for reading data from various sources like files, buffers, and streams.
§Examples
use codeq::Decode;
let data = b"\x00\x00\x00\x05hello";
let decoded = String::decode(&data[..]).unwrap();
assert_eq!(decoded, "hello");Required Methods§
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.