SixBitCodec

Struct SixBitCodec 

Source
pub struct SixBitCodec { /* private fields */ }
Expand description

A Six Bit Codec encodes 3x eight-bit bytes (24 bits) into 4x six-bit symbols. Likewise, reads 4x six-bit symbols and decodes them into 3x eight-bit bytes.

The alphabet size is 2^6 = 64 symbols.

Implementations§

Source§

impl SixBitCodec

Source

pub fn new(alphabet: &'static [u8; 64]) -> Self

Creates a new codec, using the provided alphabet.

Source

pub fn set_pad(&mut self, pad: u8) -> &mut Self

sets the end padding character (defaults to '=')

Source

pub fn set_fail_on_invalid_character(&mut self) -> &mut Self

if set, decoding will return an error on invalid character - otherwise will just skip it.

Trait Implementations§

Source§

impl Codec for SixBitCodec

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.
Source§

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

Available on crate feature alloc only.
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>

Available on crate feature alloc only.
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>

Available on crate feature alloc only.
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>

Available on crate feature alloc only.
Reads the entirety of input in coded format, and produces the results in an owned Vec

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> MaybeInto<U> for T
where U: MaybeFrom<T>,

Source§

fn maybe_into(self) -> Option<U>

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.