[−][src]Struct defmt::Display2Format
An "adapter" type to feed Display
values into defmt macros, which expect defmt::Format
values.
This adapter disables compression! You should prefer defmt::Format
over Display
whenever
possible.
This adapter works by formatting the Display
value into a stack-allocated buffer. You need to
specify how large that buffer is. If you pick a size that's too small an incomplete string
will be transmitted.
The size of the stack-allocated array is specified using one of the type-level integers in the
consts
module. Example:
use core::fmt; use defmt::{consts, Display2Format}; struct SocketAddr { ip: [u8; 4], port: u16, } impl fmt::Display for SocketAddr { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}.{}.{}.{}:{}", self.ip[0], self.ip[1], self.ip[2], self.ip[3], self.port) } } let addr = SocketAddr { ip: [127, 0, 0, 1], port: 8888 }; defmt::info!("{:?}", Display2Format::<consts::U32>(&addr)); // ^^^^^^^^^^^ size = 32 bytes // -> 0.000000 INFO 127.0.0.1:8888
Trait Implementations
impl<N, '_> Format for Display2Format<'_, N> where
N: ArrayLength<u8>,
[src]
N: ArrayLength<u8>,
Auto Trait Implementations
impl<'a, N> !Send for Display2Format<'a, N>
impl<'a, N> !Sync for Display2Format<'a, N>
impl<'a, N> Unpin for Display2Format<'a, N> where
N: Unpin,
N: Unpin,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,