Skip to main content

Filter

Trait Filter 

Source
pub trait Filter: 'static {
    // Required methods
    fn query(&self, id: TypeId) -> Option<Box<dyn Any>>;
    fn process_read_buf(&self, ctx: &mut FilterCtx<'_>) -> Result<()>;
    fn process_write_buf(&self, ctx: &mut FilterCtx<'_>) -> Result<()>;
    fn shutdown(&self, ctx: &mut FilterCtx<'_>) -> Result<Poll<()>>;
    fn poll_read_ready(&self, cx: &mut Context<'_>) -> Poll<Readiness>;
    fn poll_write_ready(&self, cx: &mut Context<'_>) -> Poll<Readiness>;
}
Expand description

Complete filter-chain interface used by Io.

Most filters should implement FilterLayer and be installed with Io::add_filter. Implement this trait directly only when wrapping or replacing a complete chain.

Required Methods§

Source

fn query(&self, id: TypeId) -> Option<Box<dyn Any>>

Returns type-indexed information exposed by this chain.

Source

fn process_read_buf(&self, ctx: &mut FilterCtx<'_>) -> Result<()>

Processes incoming data from the transport toward the application.

Source

fn process_write_buf(&self, ctx: &mut FilterCtx<'_>) -> Result<()>

Processes outgoing data from the application toward the transport.

Source

fn shutdown(&self, ctx: &mut FilterCtx<'_>) -> Result<Poll<()>>

Performs graceful shutdown from the outermost layer toward the transport.

Source

fn poll_read_ready(&self, cx: &mut Context<'_>) -> Poll<Readiness>

Checks whether transport read operations may proceed.

Reads continue through the filter shutdown phase so that filters can complete theirs, and are paused for the transport shutdown phase, so Readiness::Close is resolved only once the connection is terminated. A force close reports Readiness::Terminate instead, which releases the connection without a graceful close. That decision is made by IoContext rather than by the chain, so that it survives the chain being dropped along with Io.

Source

fn poll_write_ready(&self, cx: &mut Context<'_>) -> Poll<Readiness>

Checks whether transport write operations may proceed.

Resolves to Readiness::Close once the connection enters a graceful shutdown and all buffered output has reached the transport, or as soon as it ends because of a failure. See poll_read_ready for the force-close case.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl Filter for Base

Source§

impl Filter for Sealed

Source§

impl<F, L> Filter for Layer<F, L>
where F: FilterLayer, L: Filter,