pub struct BatchBuffer { /* private fields */ }Expand description
Accumulates encoded bytes and flushes them to a BatchSink in one write.
Append with push_str / push_bytes,
or via write! (it implements core::fmt::Write); then
flush_to writes the accumulation in a single
BatchSink::write_batch and clears for reuse.
Implementations§
Source§impl BatchBuffer
impl BatchBuffer
pub fn new() -> Self
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Preallocate capacity bytes — size it to a batch’s typical total so the
accumulation does not grow mid-batch.
Sourcepub fn push_str(&mut self, text: &str)
pub fn push_str(&mut self, text: &str)
Append a UTF-8 string — the common case (a formatted log/metric line).
Sourcepub fn push_bytes(&mut self, bytes: &[u8])
pub fn push_bytes(&mut self, bytes: &[u8])
Append raw bytes — for binary wire formats.
pub fn is_empty(&self) -> bool
pub fn len(&self) -> usize
Sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Bytes reserved in the backing allocation (>= the with_capacity request).
A batch that stays under this never reallocates mid-accumulation.
pub fn as_bytes(&self) -> &[u8] ⓘ
Trait Implementations§
Source§impl Debug for BatchBuffer
impl Debug for BatchBuffer
Source§impl Default for BatchBuffer
impl Default for BatchBuffer
Auto Trait Implementations§
impl Freeze for BatchBuffer
impl RefUnwindSafe for BatchBuffer
impl Send for BatchBuffer
impl Sync for BatchBuffer
impl Unpin for BatchBuffer
impl UnsafeUnpin for BatchBuffer
impl UnwindSafe for BatchBuffer
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