ByteEncoder

Trait ByteEncoder 

Source
pub trait ByteEncoder: BaseEncoder {
    // Required methods
    fn put_slice(&mut self, slice: &[u8]) -> Result<(), Self::Error>;
    fn put_byte(&mut self, byte: u8) -> Result<(), Self::Error>;
}
Expand description

A trait for encoders that can handle byte encodables.

This trait extends BaseEncoder to include types and methods specifically used for handling any kind of byte encodables. Encoders may use this trait as bounds for generic encodables to signal that the output will be any kind of byte steam.

Note that all ByteEncoders also implement StrEncoder.

Required Methods§

Source

fn put_slice(&mut self, slice: &[u8]) -> Result<(), Self::Error>

Writes a slice of bytes into the encoder.

§Errors

Returns an error if the encoder cannot write the entire slice due to capacity limits, encoding errors, or internal failures.

Source

fn put_byte(&mut self, byte: u8) -> Result<(), Self::Error>

Writes a single byte into the encoder.

§Errors

Returns an error if the encoder cannot write the byte due to capacity limits, encoding errors, or internal failures.

Implementations on Foreign Types§

Source§

impl ByteEncoder for &mut [u8]

Source§

fn put_slice(&mut self, slice: &[u8]) -> Result<(), Self::Error>

Source§

fn put_byte(&mut self, byte: u8) -> Result<(), Self::Error>

Source§

impl ByteEncoder for ()

Source§

fn put_slice(&mut self, _: &[u8]) -> Result<(), Self::Error>

Source§

fn put_byte(&mut self, _: u8) -> Result<(), Self::Error>

Source§

impl ByteEncoder for Vec<u8>

Source§

fn put_slice(&mut self, slice: &[u8]) -> Result<(), Self::Error>

Source§

fn put_byte(&mut self, byte: u8) -> Result<(), Self::Error>

Source§

impl ByteEncoder for BytesMut

Source§

fn put_slice(&mut self, slice: &[u8]) -> Result<(), Self::Error>

Source§

fn put_byte(&mut self, byte: u8) -> Result<(), Self::Error>

Source§

impl<const SIZE: usize> ByteEncoder for ArrayVec<u8, SIZE>

Source§

fn put_slice(&mut self, slice: &[u8]) -> Result<(), Self::Error>

Source§

fn put_byte(&mut self, byte: u8) -> Result<(), Self::Error>

Implementors§