Trait print_bytes::ToBytes [−][src]
Expand description
Represents a type similarly to Display.
Implement this trait to allow printing a type that cannot guarantee UTF-8 output. It is used to bound values accepted by functions in this crate.
Examples
use print_bytes::println_bytes;
use print_bytes::ByteStr;
use print_bytes::ToBytes;
#[cfg(windows)]
use print_bytes::WideStr;
struct ByteSlice<'a>(&'a [u8]);
impl ToBytes for ByteSlice<'_> {
fn to_bytes(&self) -> ByteStr<'_> {
self.0.to_bytes()
}
#[cfg(windows)]
fn to_wide(&self) -> Option<WideStr> {
self.0.to_wide()
}
}
println_bytes(&ByteSlice(b"Hello, world!"));Required methods
Returns a byte string that will be used to represent the instance.
This is supported on Windows only.