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
impl SixBitCodec
Sourcepub fn new(alphabet: &'static [u8; 64]) -> Self
pub fn new(alphabet: &'static [u8; 64]) -> Self
Creates a new codec, using the provided alphabet.
Sourcepub fn set_pad(&mut self, pad: u8) -> &mut Self
pub fn set_pad(&mut self, pad: u8) -> &mut Self
sets the end padding character (defaults to '=')
Sourcepub fn set_fail_on_invalid_character(&mut self) -> &mut Self
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
impl Codec for SixBitCodec
Source§fn encode<I: Bits, O: MutBits>(
&self,
input: I,
output: &mut O,
) -> Result<usize, Error>
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>
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>
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>
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
Auto Trait Implementations§
impl Freeze for SixBitCodec
impl RefUnwindSafe for SixBitCodec
impl Send for SixBitCodec
impl Sync for SixBitCodec
impl Unpin for SixBitCodec
impl UnwindSafe for SixBitCodec
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more