pub trait DisplayBytes {
// Required method
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§
fn display_bytes(&self, output: &mut dyn Write) -> Result<()>
Implementations on Foreign Types§
Source§impl DisplayBytes for f32
Format to ASCII bytes with std::fmt::Display
.
impl DisplayBytes for f32
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.
Source§impl DisplayBytes for f64
Format to ASCII bytes with std::fmt::Display
.
impl DisplayBytes for f64
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.
Source§impl DisplayBytes for i8
Format to ASCII bytes with std::fmt::Display
.
impl DisplayBytes for i8
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.
Source§impl DisplayBytes for i16
Format to ASCII bytes with std::fmt::Display
.
impl DisplayBytes for i16
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.
Source§impl DisplayBytes for i32
Format to ASCII bytes with std::fmt::Display
.
impl DisplayBytes for i32
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.
Source§impl DisplayBytes for i64
Format to ASCII bytes with std::fmt::Display
.
impl DisplayBytes for i64
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.
Source§impl DisplayBytes for i128
Format to ASCII bytes with std::fmt::Display
.
impl DisplayBytes for i128
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.
Source§impl DisplayBytes for isize
Format to ASCII bytes with std::fmt::Display
.
impl DisplayBytes for isize
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.
Source§impl DisplayBytes for u8
Format to ASCII bytes with std::fmt::Display
.
impl DisplayBytes for u8
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.
Source§impl DisplayBytes for u16
Format to ASCII bytes with std::fmt::Display
.
impl DisplayBytes for u16
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.
Source§impl DisplayBytes for u32
Format to ASCII bytes with std::fmt::Display
.
impl DisplayBytes for u32
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.
Source§impl DisplayBytes for u64
Format to ASCII bytes with std::fmt::Display
.
impl DisplayBytes for u64
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.
Source§impl DisplayBytes for u128
Format to ASCII bytes with std::fmt::Display
.
impl DisplayBytes for u128
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.
Source§impl DisplayBytes for usize
Format to ASCII bytes with std::fmt::Display
.
impl DisplayBytes for usize
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.
Source§impl DisplayBytes for Vec<u8>
Byte strings are “formatted” as-is.
impl DisplayBytes for Vec<u8>
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 0]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 0]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 1]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 1]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 2]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 2]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 3]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 3]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 4]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 4]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 5]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 5]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 6]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 6]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 7]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 7]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 8]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 8]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 9]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 9]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 10]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 10]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 11]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 11]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 12]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 12]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 13]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 13]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 14]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 14]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 15]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 15]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 16]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 16]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 17]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 17]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 18]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 18]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 19]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 19]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 20]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 20]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 21]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 21]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 22]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 22]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 23]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 23]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 24]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 24]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 25]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 25]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 26]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 26]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 27]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 27]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 28]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 28]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 29]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 29]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 30]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 30]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 31]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 31]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 32]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 32]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 33]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 33]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 34]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 34]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 35]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 35]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 36]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 36]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 37]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 37]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 38]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 38]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 39]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 39]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 40]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 40]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 41]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 41]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 42]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 42]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 43]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 43]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 44]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 44]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 45]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 45]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 46]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 46]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 47]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 47]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 48]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 48]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 49]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 49]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 50]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 50]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 51]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 51]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 52]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 52]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 53]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 53]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 54]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 54]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 55]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 55]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 56]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 56]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 57]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 57]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 58]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 58]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 59]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 59]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 60]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 60]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 61]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 61]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 62]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 62]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 63]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 63]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8; 64]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8; 64]
Byte strings are “formatted” as-is.
Source§impl DisplayBytes for [u8]
Byte strings are “formatted” as-is.
impl DisplayBytes for [u8]
Byte strings are “formatted” as-is.
Source§impl<Inner> DisplayBytes for Cow<'_, Inner>
Forward to the inner type.
impl<Inner> DisplayBytes for Cow<'_, Inner>
Forward to the inner type.
Source§impl<Inner: ?Sized + DisplayBytes> DisplayBytes for &Inner
Forward to the inner type.
impl<Inner: ?Sized + DisplayBytes> DisplayBytes for &Inner
Forward to the inner type.
Source§impl<Inner: ?Sized + DisplayBytes> DisplayBytes for &mut Inner
Forward to the inner type.
impl<Inner: ?Sized + DisplayBytes> DisplayBytes for &mut Inner
Forward to the inner type.
Source§impl<Inner: ?Sized + DisplayBytes> DisplayBytes for Box<Inner>
Forward to the inner type.
impl<Inner: ?Sized + DisplayBytes> DisplayBytes for Box<Inner>
Forward to the inner type.
Source§impl<Inner: ?Sized + DisplayBytes> DisplayBytes for Rc<Inner>
Forward to the inner type.
impl<Inner: ?Sized + DisplayBytes> DisplayBytes for Rc<Inner>
Forward to the inner type.
Source§impl<Inner: ?Sized + DisplayBytes> DisplayBytes for Arc<Inner>
Forward to the inner type.
impl<Inner: ?Sized + DisplayBytes> DisplayBytes for Arc<Inner>
Forward to the inner type.