Crate display_bytes [−] [src]
Human-readable display of byte sequences.
Supports printing of both UTF-8 and ASCII-only sequences.
For easy usage, see the free functions display_bytes()
and display_bytes_string()
in this crate. For more control over formatting, see the statics in this crate or build
an instance of DisplayBytesConfig
yourself.
extern crate display_bytes; use display_bytes::{display_bytes, display_bytes_string}; fn main() { let bytes = b"Hello, world!\x89\x90\xAB\xCD"; println!("{:?}", bytes); println!("{}", display_bytes(bytes)); assert_eq!(display_bytes_string(bytes), "Hello, world! {{ 89 90 AB CD }} "); }
Structs
DisplayBytes |
A wrapper around a byte sequence which implements |
DisplayBytesConfig |
Configuration builder for |
FormatBase64 |
Formats byte sequences in Base-64. |
FormatHex |
Formats bytes in hexadecimal pairs ( |
Constants
DEFAULT_HEX |
Default hexadecimal byte format used by this crate. |
Statics
BASE64_ASCII |
Prints byte sections as Base-64 wrapped in |
BASE64_UTF8 |
Prints byte sections as Base-64 wrapped in |
HEX_ASCII |
Prints byte sections with hexadecimal bytes wrapped in |
HEX_UTF8 |
Prints byte sections with hexadecimal bytes wrapped in |
Traits
ByteFormat |
Formats byte sequences in human-readable representations. |
Functions
display_bytes |
Wrap a byte slice in an adapter which implements |
display_bytes_string |
Attempt to convert the byte slice to a string, or else format it to a string using the default
|