pub trait ByteParser<P> {
type Bytes: AsRef<[u8]>;
const EXPECTED_LEN: Option<usize> = None;
// Provided methods
fn from_bytes_with(bytes: &[u8], params: P) -> Result<Self, Error>
where Self: Sized + Decoder<P> { ... }
fn to_bytes_with(&self, params: P) -> Result<Self::Bytes, Error>
where Self: Encoder<P>,
Self::Bytes: TryFrom<Vec<u8>> { ... }
fn from_bytes(bytes: &[u8]) -> Result<Self, Error>
where Self: Sized + Decoder<()> { ... }
fn to_bytes(&self) -> Result<Self::Bytes, Error>
where Self: Encoder<()>,
Self::Bytes: TryFrom<Vec<u8>> { ... }
}Expand description
Adapter trait: convert to/from an owned byte container using Encoder/Decoder.
Provided Associated Constants§
Sourceconst EXPECTED_LEN: Option<usize> = None
const EXPECTED_LEN: Option<usize> = None
Expected size of the byte container
Required Associated Types§
Provided Methods§
Sourcefn from_bytes_with(bytes: &[u8], params: P) -> Result<Self, Error>
fn from_bytes_with(bytes: &[u8], params: P) -> Result<Self, Error>
Decode from an owned byte container with params.
Sourcefn to_bytes_with(&self, params: P) -> Result<Self::Bytes, Error>
fn to_bytes_with(&self, params: P) -> Result<Self::Bytes, Error>
Encode into an owned byte container with params.
Sourcefn from_bytes(bytes: &[u8]) -> Result<Self, Error>
fn from_bytes(bytes: &[u8]) -> Result<Self, Error>
Helper from_bytes Function in case no parameters are needed
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".