pub struct FuncCodeWriter<E: Endianness, CW: CodesWrite<E> + ?Sized>(/* private fields */);Expand description
A newtype containing a function pointer dispatching the write method for a code.
This is a more efficient way to pass a StaticCodeWrite to a method, as
a FuncCodeWriter does not need to do a runtime test to dispatch the
correct code.
Instances can be obtained by calling the new method with a variant of
the Codes enum, or by calling the new_with_func method with a
function pointer.
Note that since selection of the code happens in the new method, it is
more efficient to clone a FuncCodeWriter than to create a new one.
Implementations§
Source§impl<E: Endianness, CW: CodesWrite<E> + ?Sized> FuncCodeWriter<E, CW>
impl<E: Endianness, CW: CodesWrite<E> + ?Sized> FuncCodeWriter<E, CW>
Sourcepub const fn new(code: Codes) -> Result<Self, DispatchError>
pub const fn new(code: Codes) -> Result<Self, DispatchError>
Returns a new FuncCodeWriter for the given code.
The code is canonicalized before the lookup, so equivalent codes yield the same writer.
§Errors
The method will return an error if there is no constant
for the given code in FuncCodeWriter.
Sourcepub const fn new_with_func(
write_func: fn(&mut CW, u64) -> Result<usize, <CW as BitWrite<E>>::Error>,
) -> Self
pub const fn new_with_func( write_func: fn(&mut CW, u64) -> Result<usize, <CW as BitWrite<E>>::Error>, ) -> Self
Returns a new FuncCodeWriter for the given function.
Trait Implementations§
Source§impl<E: Endianness, CW: CodesWrite<E> + ?Sized> Clone for FuncCodeWriter<E, CW>
impl<E: Endianness, CW: CodesWrite<E> + ?Sized> Clone for FuncCodeWriter<E, CW>
impl<E: Copy + Endianness, CW: Copy + CodesWrite<E> + ?Sized> Copy for FuncCodeWriter<E, CW>
Source§impl<E: Debug + Endianness, CW: Debug + CodesWrite<E> + ?Sized> Debug for FuncCodeWriter<E, CW>
impl<E: Debug + Endianness, CW: Debug + CodesWrite<E> + ?Sized> Debug for FuncCodeWriter<E, CW>
Source§impl<E: Endianness, CW: CodesWrite<E> + ?Sized> FlatType for FuncCodeWriter<E, CW>
impl<E: Endianness, CW: CodesWrite<E> + ?Sized> FlatType for FuncCodeWriter<E, CW>
Source§impl<E: Endianness, CW: CodesWrite<E> + ?Sized> MemDbgImpl for FuncCodeWriter<E, CW>
impl<E: Endianness, CW: CodesWrite<E> + ?Sized> MemDbgImpl for FuncCodeWriter<E, CW>
Source§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_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
self below the current line. Read moreSource§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>
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>
self at the given depth without any reference-address
annotation; forwards to _mem_dbg_depth_on_impl
with RefDisplay::None.