Trait ct_codecs::Encoder

source ·
pub trait Encoder {
    // Required methods
    fn encoded_len(bin_len: usize) -> Result<usize, Error>;
    fn encode<IN: AsRef<[u8]>>(
        encoded: &mut [u8],
        bin: IN,
    ) -> Result<&[u8], Error>;

    // Provided methods
    fn encode_to_str<IN: AsRef<[u8]>>(
        encoded: &mut [u8],
        bin: IN,
    ) -> Result<&str, Error> { ... }
    fn encode_to_string<IN: AsRef<[u8]>>(bin: IN) -> Result<String, Error> { ... }
}

Required Methods§

source

fn encoded_len(bin_len: usize) -> Result<usize, Error>

Length of bin_len bytes after encoding.

source

fn encode<IN: AsRef<[u8]>>(encoded: &mut [u8], bin: IN) -> Result<&[u8], Error>

Encode bin into encoded. The output buffer can be larger than required; the returned slice is a view of the buffer with the correct length.

Provided Methods§

source

fn encode_to_str<IN: AsRef<[u8]>>( encoded: &mut [u8], bin: IN, ) -> Result<&str, Error>

Encode bin into encoded, return the result as a str. The output buffer can be larger than required; the returned slice is a view of the buffer with the correct length.

source

fn encode_to_string<IN: AsRef<[u8]>>(bin: IN) -> Result<String, Error>

Encode bin as a String.

Object Safety§

This trait is not object safe.

Implementors§