pub struct MemorySink { /* private fields */ }Expand description
Keeps the newest record lines in memory, dropping the oldest past its
capacity (default 100 000 lines) or its byte limit (default 64 MiB),
and counting what it dropped. Input: lines. Output: lines() copies
and dropped().
Implementations§
Source§impl MemorySink
impl MemorySink
Sourcepub fn new(capacity: usize) -> MemorySink
pub fn new(capacity: usize) -> MemorySink
Returns an empty sink holding at most capacity lines, at least 1.
Input: the capacity. Output: the sink.
Sourcepub fn with_max_bytes(self, max_bytes: usize) -> MemorySink
pub fn with_max_bytes(self, max_bytes: usize) -> MemorySink
Sets the byte limit of the kept lines, at least 1. A line longer than the limit is dropped and counted. Input: bytes. Output: the sink.
Sourcepub fn lines(&self) -> Vec<String>
pub fn lines(&self) -> Vec<String>
Returns a copy of the kept lines, oldest first. Input: none.
Trait Implementations§
Source§impl Default for MemorySink
impl Default for MemorySink
Source§fn default() -> MemorySink
fn default() -> MemorySink
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !Freeze for MemorySink
impl Forget for MemorySink
impl Move for MemorySink
impl RefUnwindSafe for MemorySink
impl Send for MemorySink
impl Sync for MemorySink
impl Unpin for MemorySink
impl UnsafeUnpin for MemorySinkwhere
Align4<u32>: UnsafeUnpin,
Align1<u8>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<String>: UnsafeUnpin,
Align8<u64>: UnsafeUnpin,
impl UnwindSafe for MemorySink
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