Trait irox_tools::codec::Codec

source ·
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§

source

fn encode<I: Bits, O: MutBits>( &self, input: I, output: &mut O ) -> Result<usize, Error>

Encodes the input, writing to output. Returns the total number of bytes written.

source

fn decode<I: Bits, O: MutBits>( &self, input: I, output: &mut O ) -> Result<usize, Error>

Decodes the input, writing to output. Returns the total number of bytes written.

Provided Methods§

source

fn encode_to_str<I: Bits>(&self, input: I) -> Result<String, Error>

Reads the entirety of the input in the raw format, and produces the encoded UTF-8 results in an owned string.

source

fn encode_to_vec<I: Bits>(&self, input: I) -> Result<Vec<u8>, Error>

Reads the entirety of the input in the raw format, and produces the encoded results in an owned Vec

source

fn decode_to_str_lossy<I: Bits>(&self, input: I) -> Result<String, Error>

Reads the entirety of input in coded format, and produces the results in an owned UTF-8 encoded string, dropping any non-UTF-8 characters.

source

fn decode_to_vec<I: Bits>(&self, input: I) -> Result<Vec<u8>, Error>

Reads the entirety of input in coded format, and produces the results in an owned Vec

Object Safety§

This trait is not object safe.

Implementors§