pub struct FormattedBytes { /* private fields */ }Expand description
A stack-allocated buffer containing the formatted byte string.
FormattedBytes calculates the formatting upon instantiation and stores
the result internally. It can be cheaply converted to a &str or &[u8].
Implementations§
Source§impl FormattedBytes
impl FormattedBytes
Sourcepub fn as_bytes(&self) -> &[u8]
pub fn as_bytes(&self) -> &[u8]
Returns the formatted output as a raw byte slice.
Useful for direct std::io::Write usage.
Sourcepub fn as_str(&self) -> Result<&str, Utf8Error>
pub fn as_str(&self) -> Result<&str, Utf8Error>
Returns the formatted output as a UTF-8 string slice.
§Errors
Returns a core::str::Utf8Error if the internal buffer contains
invalid UTF-8 bytes. (Note: The format method only writes valid
ASCII characters, so this is guaranteed to succeed in practice).
Trait Implementations§
Source§impl Clone for FormattedBytes
impl Clone for FormattedBytes
Source§fn clone(&self) -> FormattedBytes
fn clone(&self) -> FormattedBytes
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Display for FormattedBytes
Allows FormattedBytes to be used in standard Rust formatting macros
(e.g., format!(), println!(), write!()).
impl Display for FormattedBytes
Allows FormattedBytes to be used in standard Rust formatting macros
(e.g., format!(), println!(), write!()).
Source§impl Format for FormattedBytes
Available on crate feature defmt only.Allow FormattedBytes to be logged seamlessly in resource-constrained
embedded environments using the defmt framework.
impl Format for FormattedBytes
defmt only.Allow FormattedBytes to be logged seamlessly in resource-constrained
embedded environments using the defmt framework.