pub struct Buffer<const N: usize> { /* private fields */ }Expand description
Static buffer to hold written text.
Implementation of ToStr must write it from the end.
§Buffer size limit
Buffer size cannot be greater than 255.
Following code will fail at compile time:
§Invalid buffer creation
to_str::Buffer::<256>::new();;§Formatting with buffer overflow
to_str::Buffer::<1>::new().format_u8(255);Implementations§
Source§impl<const N: usize> Buffer<N>
impl<const N: usize> Buffer<N>
Sourcepub const fn as_str(&self) -> &str
pub const fn as_str(&self) -> &str
Access str from underlying storage
Returns empty if nothing has been written into buffer yet.
Sourcepub fn write<T: ToStr>(&mut self, val: T) -> &str
pub fn write<T: ToStr>(&mut self, val: T) -> &str
Formats value into buffer, returning text.
Buffer remembers the write, therefore as_str() will return the same text as last
write
Source§impl<const N: usize> Buffer<N>
impl<const N: usize> Buffer<N>
Sourcepub const fn format_u8(&mut self, val: u8) -> &str
pub const fn format_u8(&mut self, val: u8) -> &str
Specialized const format of u8 value into buffer, returning text.
Sourcepub const fn format_u16(&mut self, val: u16) -> &str
pub const fn format_u16(&mut self, val: u16) -> &str
Specialized const format of u16 value into buffer, returning text.
Sourcepub const fn format_u32(&mut self, val: u32) -> &str
pub const fn format_u32(&mut self, val: u32) -> &str
Specialized const format of u32 value into buffer, returning text.
Sourcepub const fn format_u64(&mut self, val: u64) -> &str
pub const fn format_u64(&mut self, val: u64) -> &str
Specialized const format of u64 value into buffer, returning text.
Sourcepub const fn format_usize(&mut self, val: usize) -> &str
pub const fn format_usize(&mut self, val: usize) -> &str
Specialized const format of usize value into buffer, returning text.
Sourcepub const fn format_u128(&mut self, val: u128) -> &str
pub const fn format_u128(&mut self, val: u128) -> &str
Specialized const format of u128 value into buffer, returning text.
Source§impl<const N: usize> Buffer<N>
impl<const N: usize> Buffer<N>
Sourcepub const fn format_i8(&mut self, val: i8) -> &str
pub const fn format_i8(&mut self, val: i8) -> &str
Specialized const format of i8 value into buffer, returning text.
Sourcepub const fn format_i16(&mut self, val: i16) -> &str
pub const fn format_i16(&mut self, val: i16) -> &str
Specialized const format of i16 value into buffer, returning text.
Sourcepub const fn format_i32(&mut self, val: i32) -> &str
pub const fn format_i32(&mut self, val: i32) -> &str
Specialized const format of i32 value into buffer, returning text.
Sourcepub const fn format_i64(&mut self, val: i64) -> &str
pub const fn format_i64(&mut self, val: i64) -> &str
Specialized const format of i64 value into buffer, returning text.
Sourcepub const fn format_isize(&mut self, val: isize) -> &str
pub const fn format_isize(&mut self, val: isize) -> &str
Specialized const format of isize value into buffer, returning text.
Sourcepub const fn format_i128(&mut self, val: i128) -> &str
pub const fn format_i128(&mut self, val: i128) -> &str
Specialized const format of i128 value into buffer, returning text.