pub trait Filter: 'static {
// Required methods
fn query(&self, id: TypeId) -> Option<Box<dyn Any>>;
fn process_read_buf(&self, ctx: &mut FilterCtx<'_>) -> Result<(), Error>;
fn process_write_buf(&self, ctx: &mut FilterCtx<'_>) -> Result<(), Error>;
fn shutdown(&self, ctx: &mut FilterCtx<'_>) -> Result<Poll<()>, Error>;
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§
Sourcefn query(&self, id: TypeId) -> Option<Box<dyn Any>>
fn query(&self, id: TypeId) -> Option<Box<dyn Any>>
Returns type-indexed information exposed by this chain.
Sourcefn process_read_buf(&self, ctx: &mut FilterCtx<'_>) -> Result<(), Error>
fn process_read_buf(&self, ctx: &mut FilterCtx<'_>) -> Result<(), Error>
Processes incoming data from the transport toward the application.
Sourcefn process_write_buf(&self, ctx: &mut FilterCtx<'_>) -> Result<(), Error>
fn process_write_buf(&self, ctx: &mut FilterCtx<'_>) -> Result<(), Error>
Processes outgoing data from the application toward the transport.
Sourcefn shutdown(&self, ctx: &mut FilterCtx<'_>) -> Result<Poll<()>, Error>
fn shutdown(&self, ctx: &mut FilterCtx<'_>) -> Result<Poll<()>, Error>
Performs graceful shutdown from the outermost layer toward the transport.
Sourcefn poll_read_ready(&self, cx: &mut Context<'_>) -> Poll<Readiness>
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.
Sourcefn poll_write_ready(&self, cx: &mut Context<'_>) -> Poll<Readiness>
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".