Struct carboncopy_tokio::BufSink[][src]

pub struct BufSink<T: AsyncWriteExt + Unpin + Send + 'static> { /* fields omitted */ }
Expand description

A sink with memory buffer and periodic flusher built with Tokio facilities so it is suitable for binaries relying on the Tokio executor. It can also be used by async-blind library clients since the Sink trait offers blocking API.

Its mutable interior is guarded by Arc<Mutex<...>>.

Implementations

impl<T: AsyncWriteExt + Unpin + Send + 'static> BufSink<T>[src]

pub fn new(opts: SinkOptions<T>) -> Self[src]

At the same time as the instantiation, a flusher task is spawned in the background whose job is to flush after the buffer overflows or a set timeout has elapsed (whichever happens first).

The flusher task will terminate when the instance is dropped.

pub async fn flush(&self) -> Result<usize>[src]

Attempts to manually flush the underlying buffer to Stdout.

pub async fn backlogged(&self) -> bool[src]

Checks if buffer flushing is being backlogged (not necessarily by errors).

pub fn last_flush_err(&self) -> Option<Arc<Error>>[src]

Checks if the flusher has just encountered an error. Only use this function to check for long running errors. A temporary error could already be cleared by retries by the time you call this function.

A bufferless sink will always return None.

Trait Implementations

impl<T: AsyncWriteExt + Unpin + Send + 'static> Drop for BufSink<T>[src]

fn drop(&mut self)[src]

Executes the destructor for this type. Read more

impl<T: AsyncWriteExt + Unpin + Send + 'static> Sink for BufSink<T>[src]

fn sink_blocking(&self, entry: String) -> Result<()>[src]

Sinks a log entry and blocks the current thread while waiting for I/O completion for async blind callers that want to wait for acknowledgment. Example implementation is block_on(/* I/O logic */). Refer to the block_on API offered by tokio, async-std, etc. Read more

fn sink(&self, entry: String) -> BoxFuture<'_, Result<()>>[src]

Sinks a log entry using async I/O and returns a future to be await-ed by the caller. Caller must likely use the same executor as Sink implementation. Read more

Auto Trait Implementations

impl<T> !RefUnwindSafe for BufSink<T>

impl<T> Send for BufSink<T>

impl<T> Sync for BufSink<T>

impl<T> Unpin for BufSink<T>

impl<T> !UnwindSafe for BufSink<T>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.