pub struct MemBufStr<'a> { /* private fields */ }Available on crate feature
format only.Expand description
A structure which acts similar to a FixedBufStr but borrows from a buffer instead of owning a stack allocation.
Implementations§
Source§impl<'a> MemBufStr<'a>
impl<'a> MemBufStr<'a>
Sourcepub unsafe fn wrap_uninit(
len: &'a mut usize,
buffer: &'a mut [MaybeUninit<u8>],
) -> MemBufStr<'a>
pub unsafe fn wrap_uninit( len: &'a mut usize, buffer: &'a mut [MaybeUninit<u8>], ) -> MemBufStr<'a>
Wraps a memory buffer with its length in a new string buffer.
§Safety
It is UB to construct a MemBufStr if len is not a valid position in the buffer buffer.
It is also UB to construct a MemBufStr from a buffer which does not contain only UTF-8
bytes. If len points to uninitialized memory in buffer constructing MemBufStr is UB.
Sourcepub unsafe fn write(&mut self, buf: &[u8]) -> usize
pub unsafe fn write(&mut self, buf: &[u8]) -> usize
Appends a raw byte buffer at the end of this string buffer.
Returns the number of bytes written.
§Arguments
buf: the raw byte buffer to append.
returns: usize
§Safety
- MemBufStr contains only valid UTF-8 strings so buf must contain only valid UTF-8 bytes.
- If buf contains invalid UTF-8 bytes, further operations on the log message buffer may result in UB.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for MemBufStr<'a>
impl<'a> RefUnwindSafe for MemBufStr<'a>
impl<'a> Send for MemBufStr<'a>
impl<'a> Sync for MemBufStr<'a>
impl<'a> Unpin for MemBufStr<'a>
impl<'a> !UnwindSafe for MemBufStr<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more