Skip to main content

ServerHook

Trait ServerHook 

Source
pub trait ServerHook:
    Send
    + Sync
    + 'static {
    // Required methods
    fn new(ctx: &Context) -> impl Future<Output = Self> + Send;
    fn handle(self, ctx: &Context) -> impl Future<Output = ()> + Send;
}
Expand description

Trait for server lifecycle hooks that process connections.

ServerHook provides a unified interface for different types of connection processing handlers in the server lifecycle.

This trait is designed to work with the server’s connection processing pipeline.

Required Methods§

Source

fn new(ctx: &Context) -> impl Future<Output = Self> + Send

Creates a new instance of this hook from the context.

This method is called by the framework to instantiate the hook.

§Arguments
  • &Context - The connection context containing all request/response data.
§Returns

A future that resolves to a new instance of this hook.

Source

fn handle(self, ctx: &Context) -> impl Future<Output = ()> + Send

Executes the hook’s processing logic.

This method contains the actual logic for processing the connection.

§Arguments
  • &Context - The connection context for accessing request/response data.
§Returns

A future that resolves when the processing is complete.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl ServerHook for DefaultHook

Implementation of ServerHook for DefaultHook.