Skip to main content

StreamObserver

Trait StreamObserver 

Source
pub trait StreamObserver {
    // Provided methods
    fn on_read(&mut self, _filled: usize) { ... }
    fn on_write(
        &mut self,
        _cx: &mut Context<'_>,
        result: Poll<Result<usize>>,
    ) -> Poll<Result<usize>> { ... }
    fn on_flush(
        &mut self,
        _cx: &mut Context<'_>,
        result: Poll<Result<()>>,
    ) -> Poll<Result<()>> { ... }
}
Expand description

What an ObservedStream reports to.

Each method sees one poll of the wrapped stream and, for a write, flush or shutdown, returns what the caller gets. The defaults pass every outcome on unchanged.

Provided Methods§

Source

fn on_read(&mut self, _filled: usize)

A read poll moved filled bytes into the caller’s buffer.

Source

fn on_write( &mut self, _cx: &mut Context<'_>, result: Poll<Result<usize>>, ) -> Poll<Result<usize>>

A write or vectored write polled result.

Source

fn on_flush( &mut self, _cx: &mut Context<'_>, result: Poll<Result<()>>, ) -> Poll<Result<()>>

A flush or shutdown polled result.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§