pub trait Representation<const NBITS: usize> {
type Domain: Iterator<Item = i64>;
// Required methods
fn encode(value: i64) -> Result<u8, EncodingError>;
fn encode_unchecked(value: i64) -> u8;
fn decode(raw: u8) -> i64;
fn check(value: i64) -> bool;
fn domain() -> Self::Domain;
}Expand description
Representation of NBITS bit numbers in the associated domain.
Required Associated Types§
Required Methods§
Sourcefn encode(value: i64) -> Result<u8, EncodingError>
fn encode(value: i64) -> Result<u8, EncodingError>
Encode value into the lower order bits of a byte. Returns the encoded value on
success, or an EncodingError if the value is unencodable.
Sourcefn encode_unchecked(value: i64) -> u8
fn encode_unchecked(value: i64) -> u8
Encode value into the lower order bits of a byte without checking if value
is encodable. This function is not marked as unsafe because in-and-of itself, it
won’t cause memory safety issues.
This may panic in debug mode when value is outside of this representation’s
domain.
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.