pub trait SymbolCode:
Copy
+ Send
+ Sync
+ 'static {
const CODES: usize;
const BITS: u32;
// Required methods
fn at(index: usize) -> Self;
fn index(code: Self) -> usize;
fn index_stream(codes: &[Self], space: usize) -> Option<IndexStream<'_>>;
}Expand description
A code type whose own order is an enumeration’s order.
u16 and u8, and nothing else: the width is a fact about the artifact’s
storage, and the two widths are the two residencies a codec has a use for
— two bytes a symbol, and one where the code space fits a byte.
The trait exists so that Arena, Book, Sign and Ternary are
one tier at two widths rather than two tiers with one decode: the table
read, the bit fields, the enumeration, and the canonicalization are written
once, against these methods.
Required Associated Constants§
Required Methods§
Sourcefn index_stream(codes: &[Self], space: usize) -> Option<IndexStream<'_>>
fn index_stream(codes: &[Self], space: usize) -> Option<IndexStream<'_>>
The stored code stream read as the index stream it already is, when it is one.
index_of is % space at every tier here, which is & (space - 1)
exactly when the space is a power of two — and then the stored code,
masked, is the index, at either width, and the traversal borrows it.
At any other entry count the two differ and the traversal builds the
stream, at the same bytes. The variant names the width: a byte stream
answers IndexStream::U8, and the gather dispatches on it once.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".