pub struct ConstCode<const CODE: usize>;Expand description
A zero-sized struct with a const generic parameter representing a code using
the constants exported by the code_consts module.
Methods for all traits are implemented for this struct using a match on the value of the const type parameter. Since the parameter is a constant, the match is resolved at compile time, so there will be no runtime overhead.
If the value is not among those defined in the code_consts module, the
methods will panic.
See the module documentation for more information.
Implementations§
Source§impl<const CODE: usize> ConstCode<CODE>
impl<const CODE: usize> ConstCode<CODE>
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 the read method 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.
Trait Implementations§
Source§impl<const CODE: usize> DynamicCodeRead for ConstCode<CODE>
impl<const CODE: usize> DynamicCodeRead for ConstCode<CODE>
Source§impl<const CODE: usize> DynamicCodeWrite for ConstCode<CODE>
impl<const CODE: usize> DynamicCodeWrite for ConstCode<CODE>
Source§impl<const CODE: usize> MemDbgImpl for ConstCode<CODE>
impl<const CODE: usize> MemDbgImpl for ConstCode<CODE>
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>
Internal implementation for depth display. Read more
Source§impl<const CODE: usize> MemSize for ConstCode<CODE>
impl<const CODE: usize> MemSize for ConstCode<CODE>
Source§impl<E: Endianness, CR: CodesRead<E> + ?Sized, const CODE: usize> StaticCodeRead<E, CR> for ConstCode<CODE>
impl<E: Endianness, CR: CodesRead<E> + ?Sized, const CODE: usize> StaticCodeRead<E, CR> for ConstCode<CODE>
Source§impl<E: Endianness, CW: CodesWrite<E> + ?Sized, const CODE: usize> StaticCodeWrite<E, CW> for ConstCode<CODE>
impl<E: Endianness, CW: CodesWrite<E> + ?Sized, const CODE: usize> StaticCodeWrite<E, CW> for ConstCode<CODE>
impl<const CODE: usize> Copy for ConstCode<CODE>
impl<const CODE: usize> Eq for ConstCode<CODE>
impl<const CODE: usize> StructuralPartialEq for ConstCode<CODE>
Auto Trait Implementations§
impl<const CODE: usize> Freeze for ConstCode<CODE>
impl<const CODE: usize> RefUnwindSafe for ConstCode<CODE>
impl<const CODE: usize> Send for ConstCode<CODE>
impl<const CODE: usize> Sync for ConstCode<CODE>
impl<const CODE: usize> Unpin for ConstCode<CODE>
impl<const CODE: usize> UnsafeUnpin for ConstCode<CODE>
impl<const CODE: usize> UnwindSafe for ConstCode<CODE>
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
Mutably borrows from an owned value. Read more
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
Compare self to
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>
Writes to stderr debug info about the structure memory usage, expanding
all levels of nested structures.
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>
Writes to a
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>
Writes to stderr debug info about the structure memory usage as
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>
Writes to a
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.