pub struct ConstCode<const CODE: usize>;
Expand description
A zero-sized struct with a const generic parameter representing a code using
the values 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>
Delegate 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,
value: u64,
) -> Result<usize, CW::Error>
pub fn write<E: Endianness, CW: CodesWrite<E> + ?Sized>( &self, writer: &mut CW, value: u64, ) -> Result<usize, CW::Error>
Delegate 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, ) -> 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, ) -> Result<(), Error>
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> 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, U> CastableInto<U> for Twhere
U: CastableFrom<T>,
impl<T, U> CastableInto<U> for Twhere
U: CastableFrom<T>,
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DowncastableFrom<T> for T
impl<T> DowncastableFrom<T> for T
Source§fn downcast_from(value: T) -> T
fn downcast_from(value: T) -> T
Truncate the current UnsignedInt to a possibly smaller size
Source§impl<T, U> DowncastableInto<U> for Twhere
U: DowncastableFrom<T>,
impl<T, U> DowncastableInto<U> for Twhere
U: DowncastableFrom<T>,
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 infos 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 infos 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 infos 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 infos about the structure memory
usage as mem_dbg_on
, but expanding only up to
max_depth
levels of nested structures.Source§impl<T> UpcastableFrom<T> for T
impl<T> UpcastableFrom<T> for T
Source§fn upcast_from(value: T) -> T
fn upcast_from(value: T) -> T
Extend the current UnsignedInt to a possibly bigger size.