pub trait Codec {
// Required methods
fn encode<I: Bits, O: MutBits>(
&self,
input: I,
output: &mut O,
) -> Result<usize, Error>;
fn decode<I: Bits, O: MutBits>(
&self,
input: I,
output: &mut O,
) -> Result<usize, Error>;
// Provided methods
fn encode_to_str<I: Bits>(&self, input: I) -> Result<String, Error> { ... }
fn encode_to_vec<I: Bits>(&self, input: I) -> Result<Vec<u8>, Error> { ... }
fn decode_to_str_lossy<I: Bits>(&self, input: I) -> Result<String, Error> { ... }
fn decode_to_vec<I: Bits>(&self, input: I) -> Result<Vec<u8>, Error> { ... }
}Expand description
Something that can encode or decode bytes to bytes
Required Methods§
Provided Methods§
Sourcefn encode_to_str<I: Bits>(&self, input: I) -> Result<String, Error>
Available on crate feature alloc only.
fn encode_to_str<I: Bits>(&self, input: I) -> Result<String, Error>
alloc only.Reads the entirety of the input in the raw format, and produces the encoded UTF-8 results in an owned string.
Sourcefn encode_to_vec<I: Bits>(&self, input: I) -> Result<Vec<u8>, Error>
Available on crate feature alloc only.
fn encode_to_vec<I: Bits>(&self, input: I) -> Result<Vec<u8>, Error>
alloc only.Reads the entirety of the input in the raw format, and produces the encoded results in an owned Vec
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.