pub struct Base<const N: usize> { /* private fields */ }
Implementations§
Source§impl<const N: usize> Base<N>
impl<const N: usize> Base<N>
Sourcepub const fn new(chars: &[u8; N]) -> Option<Self>
pub const fn new(chars: &[u8; N]) -> Option<Self>
Creates a new alphabet for encoding/decoding. Predefined alphabets are available as constants.
Sourcepub fn encode_const_len<const LEN: usize, T: ConstLen<LEN>>(
&self,
t: &T,
) -> String
pub fn encode_const_len<const LEN: usize, T: ConstLen<LEN>>( &self, t: &T, ) -> String
Padded to the length required for the largest value.
assert_eq!(BASE10.encode_const_len(&0u8), "000");
assert_eq!(BASE10.encode_const_len(&1u8), "001");
assert_eq!(BASE10.encode_const_len(&255u8), "255");
Sourcepub fn decode_const_len<const LEN: usize, T: ConstLen<LEN>>(
&self,
s: &str,
) -> Option<T>
pub fn decode_const_len<const LEN: usize, T: ConstLen<LEN>>( &self, s: &str, ) -> Option<T>
Requires the length required for the largest value.
assert_eq!(BASE10.decode_const_len("0"), None::<u8>);
assert_eq!(BASE10.decode_const_len("000"), Some(0u8));
assert_eq!(BASE10.decode_const_len("0000"), None::<u8>);
Sourcepub fn const_len<const LEN: usize>() -> usize
pub fn const_len<const LEN: usize>() -> usize
Number of characters required to encode the largest value.
Trait Implementations§
Auto Trait Implementations§
impl<const N: usize> Freeze for Base<N>
impl<const N: usize> RefUnwindSafe for Base<N>
impl<const N: usize> Send for Base<N>
impl<const N: usize> Sync for Base<N>
impl<const N: usize> Unpin for Base<N>
impl<const N: usize> UnwindSafe for Base<N>
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