pub trait Codec:
Debug
+ Copy
+ Clone
+ PartialEq
+ Hash
+ Eq {
const BITS: u8;
// Required methods
fn unsafe_from_bits(b: u8) -> Self;
fn try_from_bits(b: u8) -> Option<Self>;
fn unsafe_from_ascii(c: u8) -> Self;
fn try_from_ascii(c: u8) -> Option<Self>;
fn to_char(self) -> char;
fn to_bits(self) -> u8;
fn items() -> impl Iterator<Item = Self>;
}Expand description
The binary encoding of an alphabet’s symbols can be represented with any type.
Encoding from ASCII bytes and decoding the representation is implemented through
the Codec trait.
The intended representation is an Enum, transparently represented as a u8.
Required Associated Constants§
Required Methods§
Sourcefn unsafe_from_bits(b: u8) -> Self
fn unsafe_from_bits(b: u8) -> Self
Convert raw bits of binary encoding into enum item. Binary values that don’t match an enum member’s discriminant will result in panic or random enum item
Sourcefn try_from_bits(b: u8) -> Option<Self>
fn try_from_bits(b: u8) -> Option<Self>
Fallibly convert raw bits into enum. If the binary value does not
match a discriminant, return None
Sourcefn unsafe_from_ascii(c: u8) -> Self
fn unsafe_from_ascii(c: u8) -> Self
Encode an ASCII byte as a codec enum item
Sourcefn try_from_ascii(c: u8) -> Option<Self>
fn try_from_ascii(c: u8) -> Option<Self>
Fallibly encode an ASCII byte as a codec enum item
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.