Trait format_bytes::DisplayBytes[][src]

pub trait DisplayBytes {
    fn display_bytes(&self, output: &mut dyn Write) -> Result<()>;
}
Expand description

Let types decide how to format themselves for presentation to users in a byte-stream output.

Similar to std::fmt::Display, but the output stream is bytes instead of Unicode.

When output is presented to users, it is decoded with an unspecified character encoding that is presumed to be ASCII-compatible.

Implementers should return any error from output (e.g. with the ? operator), and not emit other errors.

Example

A typical impl for a struct with multiple fields might use the write_bytes macro:

use format_bytes::{DisplayBytes, write_bytes};

struct Point2D { x: f32, y: f32 }

impl DisplayBytes for Point2D {
    fn display_bytes(
        &self,
        out: &mut dyn std::io::Write,
    ) -> std::io::Result<()> {
        write_bytes!(out, b"x = {}, y = {}", self.x, self.y)
    }
}

Required methods

Implementations on Foreign Types

Forward to the inner type.

Forward to the inner type.

Forward to the inner type.

Forward to the inner type.

Forward to the inner type.

Forward to the inner type.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Byte strings are “formatted” as-is.

Format to ASCII bytes with std::fmt::Display.

The Display impl for this type only emits ASCII characters, so it’s less useful than in the general case to make users explicitly opt-in to UTF-8 encoding.

Format to ASCII bytes with std::fmt::Display.

The Display impl for this type only emits ASCII characters, so it’s less useful than in the general case to make users explicitly opt-in to UTF-8 encoding.

Format to ASCII bytes with std::fmt::Display.

The Display impl for this type only emits ASCII characters, so it’s less useful than in the general case to make users explicitly opt-in to UTF-8 encoding.

Format to ASCII bytes with std::fmt::Display.

The Display impl for this type only emits ASCII characters, so it’s less useful than in the general case to make users explicitly opt-in to UTF-8 encoding.

Format to ASCII bytes with std::fmt::Display.

The Display impl for this type only emits ASCII characters, so it’s less useful than in the general case to make users explicitly opt-in to UTF-8 encoding.

Format to ASCII bytes with std::fmt::Display.

The Display impl for this type only emits ASCII characters, so it’s less useful than in the general case to make users explicitly opt-in to UTF-8 encoding.

Format to ASCII bytes with std::fmt::Display.

The Display impl for this type only emits ASCII characters, so it’s less useful than in the general case to make users explicitly opt-in to UTF-8 encoding.

Format to ASCII bytes with std::fmt::Display.

The Display impl for this type only emits ASCII characters, so it’s less useful than in the general case to make users explicitly opt-in to UTF-8 encoding.

Format to ASCII bytes with std::fmt::Display.

The Display impl for this type only emits ASCII characters, so it’s less useful than in the general case to make users explicitly opt-in to UTF-8 encoding.

Format to ASCII bytes with std::fmt::Display.

The Display impl for this type only emits ASCII characters, so it’s less useful than in the general case to make users explicitly opt-in to UTF-8 encoding.

Format to ASCII bytes with std::fmt::Display.

The Display impl for this type only emits ASCII characters, so it’s less useful than in the general case to make users explicitly opt-in to UTF-8 encoding.

Format to ASCII bytes with std::fmt::Display.

The Display impl for this type only emits ASCII characters, so it’s less useful than in the general case to make users explicitly opt-in to UTF-8 encoding.

Format to ASCII bytes with std::fmt::Display.

The Display impl for this type only emits ASCII characters, so it’s less useful than in the general case to make users explicitly opt-in to UTF-8 encoding.

Format to ASCII bytes with std::fmt::Display.

The Display impl for this type only emits ASCII characters, so it’s less useful than in the general case to make users explicitly opt-in to UTF-8 encoding.

Implementors