Struct carboncopy_tokio::BufSink [−][src]
pub struct BufSink<T: AsyncWriteExt + Unpin + Send + 'static> { /* fields omitted */ }
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]
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
Auto Trait Implementations
impl<T> !RefUnwindSafe for BufSink<T>
impl<T> !RefUnwindSafe for BufSink<T>
impl<T> !UnwindSafe for BufSink<T>
impl<T> !UnwindSafe for BufSink<T>