Expand description
Mechanisms for selecting parameters.
Traits and structures in this module are not normally needed by the typical
user. Their purpose is to provide a systematic way, and in particular
a default way, to select parameters for parameterized traits
such as GammaReadParam and GammaWriteParam.
The traits and structure in this module work closely with the
bitstream readers and writers in impls, which have an
additional type parameter RP/WP that must
implement marker traits ReadParams or WriteParams, respectively.
The type is then used as a selector type to provide blanket implementations
of parameterless traits in codes such as GammaRead,
GammaWrite, DeltaRead, DeltaWrite, and so on.
This module provides default selector types
DefaultReadParams and DefaultWriteParams which are also
the default value for the parameter RP/WP in the bitstream
readers and writers in crate::impls. Type-selected blanket
implementations of all parameterless traits in crate::codes
are provided for the bitstream readers and writers in
impls. Thus, if you do not specify a value for
the parameter RP/WP, you will obtain automatically the
blanket implementations for parameterless traits contained in
this module.
However, you can also create new selector types implementing
ReadParams/WriteParams and write blanket implementations
for the bitstream readers and writers in crate::impls where
RP/WP is set to your selector types. Then, by specifying
your type as value of the parameter RP/WP when creating such
readers and writers you will use automatically your blanket
implementations instead of the ones provided by this module.
Note that the default implementations provided by this module are targeted at
u32 read words and u64 write words. If you use different word sizes,
you may want to write your own selector types.
§Table peek-bits checks
The read_*_param methods in each code module (e.g.,
GammaReadParam::read_gamma_param) verify at compile time, via const { } blocks using BitRead::PEEK_BITS, that the reader’s peek word is large
enough for the table when the corresponding USE_TABLE const parameter is
true. These checks are short-circuited when the table is not used, so they
are only triggered for the tables actually selected.
Structs§
- Default
Read Params - A selector type for read parameters providing reasonable defaults.
- Default
Write Params - A selector type for write parameters providing reasonable defaults.
Traits§
- Read
Params - Marker trait for read-parameters selector types.
- Write
Params - Marker trait for write-parameters selector types.