#[non_exhaustive]pub enum Codes {
Unary,
Gamma,
Delta,
Omega,
VByteLe,
VByteBe,
Zeta(usize),
Pi(usize),
Golomb(u64),
ExpGolomb(usize),
Rice(usize),
}Expand description
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Unary
Gamma
Delta
Omega
VByteLe
VByteBe
Zeta(usize)
Pi(usize)
Golomb(u64)
ExpGolomb(usize)
Rice(usize)
Implementations§
Source§impl Codes
impl Codes
Sourcepub const fn canonicalize(self) -> Self
pub const fn canonicalize(self) -> Self
Returns the canonical form of this code.
Some codes are equivalent, in the sense that they are defined differently, but they give rise to the same codewords. Among equivalent codes, there is usually one that is faster to encode and decode, which we call the canonical representative of the equivalence class.
The mapping is:
Sourcepub fn read<E: Endianness, CR: CodesRead<E> + ?Sized>(
&self,
reader: &mut CR,
) -> Result<u64, CR::Error>
pub fn read<E: Endianness, CR: CodesRead<E> + ?Sized>( &self, reader: &mut CR, ) -> Result<u64, CR::Error>
Delegates to the DynamicCodeRead implementation.
This inherent method is provided to reduce ambiguity in method resolution.
Sourcepub fn write<E: Endianness, CW: CodesWrite<E> + ?Sized>(
&self,
writer: &mut CW,
n: u64,
) -> Result<usize, CW::Error>
pub fn write<E: Endianness, CW: CodesWrite<E> + ?Sized>( &self, writer: &mut CW, n: u64, ) -> Result<usize, CW::Error>
Delegates to the DynamicCodeWrite implementation.
This inherent method is provided to reduce ambiguity in method resolution.
Sourcepub const fn to_code_const(&self) -> Result<usize, DispatchError>
pub const fn to_code_const(&self) -> Result<usize, DispatchError>
Converts a code to the constants in the code_consts module used for
ConstCode. This is mostly used to verify that the code is supported
by ConstCode.
The code is canonicalized before the conversion, so equivalent codes map to the same constant.
§Errors
Returns DispatchError::UnsupportedCode if the (canonicalized)
code has no corresponding constant in code_consts.
Sourcepub const fn from_code_const(const_code: usize) -> Result<Self, DispatchError>
pub const fn from_code_const(const_code: usize) -> Result<Self, DispatchError>
Converts a value from code_consts to a code.
§Errors
Returns DispatchError::UnsupportedCodeConst if the value
does not correspond to any known code constant.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Codes
Available on crate feature serde only.
impl<'de> Deserialize<'de> for Codes
serde only.Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl DynamicCodeRead for Codes
impl DynamicCodeRead for Codes
Source§impl DynamicCodeWrite for Codes
impl DynamicCodeWrite for Codes
Source§impl MemDbgImpl for Codes
impl MemDbgImpl for Codes
fn _mem_dbg_rec_on( &self, _memdbg_writer: &mut impl Write, _memdbg_total_size: usize, _memdbg_max_depth: usize, _memdbg_prefix: &mut String, _memdbg_is_last: bool, _memdbg_flags: DbgFlags, _memdbg_refs: &mut HashSet<usize>, ) -> Result
fn _mem_dbg_depth_on( &self, writer: &mut impl Write, total_size: usize, max_depth: usize, prefix: &mut String, field_name: Option<&str>, is_last: bool, padded_size: usize, flags: DbgFlags, dbg_refs: &mut HashSet<usize>, ) -> Result<(), Error>
Source§fn _mem_dbg_depth_on_impl(
&self,
writer: &mut impl Write,
total_size: usize,
max_depth: usize,
prefix: &mut String,
field_name: Option<&str>,
is_last: bool,
padded_size: usize,
flags: DbgFlags,
dbg_refs: &mut HashSet<usize>,
ref_display: RefDisplay,
) -> Result<(), Error>
fn _mem_dbg_depth_on_impl( &self, writer: &mut impl Write, total_size: usize, max_depth: usize, prefix: &mut String, field_name: Option<&str>, is_last: bool, padded_size: usize, flags: DbgFlags, dbg_refs: &mut HashSet<usize>, ref_display: RefDisplay, ) -> Result<(), Error>
Source§impl MemSize for Codes
impl MemSize for Codes
Source§impl<E: Endianness, CR: CodesRead<E> + ?Sized> StaticCodeRead<E, CR> for Codes
impl<E: Endianness, CR: CodesRead<E> + ?Sized> StaticCodeRead<E, CR> for Codes
Source§impl<E: Endianness, CW: CodesWrite<E> + ?Sized> StaticCodeWrite<E, CW> for Codes
impl<E: Endianness, CW: CodesWrite<E> + ?Sized> StaticCodeWrite<E, CW> for Codes
impl Copy for Codes
impl Eq for Codes
impl StructuralPartialEq for Codes
Auto Trait Implementations§
impl Freeze for Codes
impl RefUnwindSafe for Codes
impl Send for Codes
impl Sync for Codes
impl Unpin for Codes
impl UnsafeUnpin for Codes
impl UnwindSafe for Codes
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> MemDbg for Twhere
T: MemDbgImpl,
impl<T> MemDbg for Twhere
T: MemDbgImpl,
Source§fn mem_dbg(&self, flags: DbgFlags) -> Result<(), Error>
fn mem_dbg(&self, flags: DbgFlags) -> Result<(), Error>
Source§fn mem_dbg_on(
&self,
writer: &mut impl Write,
flags: DbgFlags,
) -> Result<(), Error>
fn mem_dbg_on( &self, writer: &mut impl Write, flags: DbgFlags, ) -> Result<(), Error>
core::fmt::Write debug info about the structure memory
usage, expanding all levels of nested structures.Source§fn mem_dbg_depth(&self, max_depth: usize, flags: DbgFlags) -> Result<(), Error>
fn mem_dbg_depth(&self, max_depth: usize, flags: DbgFlags) -> Result<(), Error>
mem_dbg, but expanding only up to max_depth
levels of nested structures.Source§fn mem_dbg_depth_on(
&self,
writer: &mut impl Write,
max_depth: usize,
flags: DbgFlags,
) -> Result<(), Error>
fn mem_dbg_depth_on( &self, writer: &mut impl Write, max_depth: usize, flags: DbgFlags, ) -> Result<(), Error>
core::fmt::Write debug info about the structure memory
usage as mem_dbg_on, but expanding only up to
max_depth levels of nested structures.