Skip to main content

MemorySink

Struct MemorySink 

Source
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

Source

pub fn new(capacity: usize) -> MemorySink

Returns an empty sink holding at most capacity lines, at least 1. Input: the capacity. Output: the sink.

Source

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.

Source

pub fn lines(&self) -> Vec<String>

Returns a copy of the kept lines, oldest first. Input: none.

Source

pub fn dropped(&self) -> u64

Returns how many lines were dropped. Input: none. Output: the count.

Source

pub fn capacity(&self) -> usize

Returns the line capacity. Input: none. Output: the capacity.

Source

pub fn max_bytes(&self) -> usize

Returns the byte limit. Input: none. Output: the limit.

Trait Implementations§

Source§

impl Default for MemorySink

Source§

fn default() -> MemorySink

Returns the “default value” for a type. Read more
Source§

impl TraceSink for MemorySink

Source§

fn write(&self, line: &str)

Takes one record line. Errors are counted by the sink, not returned.
Source§

fn flush(&self)

Pushes buffered lines to their destination. The default does nothing. Trace points made during a flush are suppressed, as during a write.

Auto Trait Implementations§

§

impl !Freeze for MemorySink

§

impl Forget for MemorySink

§

impl Move for MemorySink

§

impl RefUnwindSafe for MemorySink
where Mutex<MemoryLines>: RefUnwindSafe, Atomic<u64>: RefUnwindSafe,

§

impl Send for MemorySink
where Mutex<MemoryLines>: Send, Atomic<u64>: Send,

§

impl Sync for MemorySink
where Mutex<MemoryLines>: Sync, Atomic<u64>: Sync,

§

impl Unpin for MemorySink
where Align4<u32>: Unpin, Align1<u8>: Unpin, *const u8 is !null: Unpin, Align8<u64>: Unpin,

§

impl UnsafeUnpin for MemorySink
where Align4<u32>: UnsafeUnpin, Align1<u8>: UnsafeUnpin, *const u8 is !null: UnsafeUnpin, PhantomData<String>: UnsafeUnpin, Align8<u64>: UnsafeUnpin,

§

impl UnwindSafe for MemorySink
where Mutex<MemoryLines>: UnwindSafe, Align8<u64>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.