[][src]Struct defmt::Display2Format

pub struct Display2Format<'a, N> where
    N: ArrayLength<u8>, 
{ /* fields omitted */ }

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]

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

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

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]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.