Skip to main content

Handler

Trait Handler 

Source
pub trait Handler:
    Send
    + Sync
    + 'static {
    // Required method
    fn handle(
        &self,
        query: &[u8],
        peer: SocketAddr,
        protocol: Protocol,
        response: &mut Vec<u8>,
    ) -> impl Future<Output = Action> + Send;

    // Provided methods
    fn udp_workers(&self) -> usize { ... }
    fn parallel_query(
        &self,
        _query: &[u8],
        _peer: SocketAddr,
    ) -> Option<Receiver<bool>> { ... }
    fn handle_shared(
        self: &Arc<Self>,
        query: &[u8],
        peer: SocketAddr,
        protocol: Protocol,
        response: &mut Vec<u8>,
    ) -> impl Future<Output = Action> + Send { ... }
}
Expand description

Async, statically dispatched Query handling. Clear and reuse the supplied Response buffer; return Drop to suppress a Response. Handlers must not block the runtime; TCP Queries on a connection may run concurrently.

Required Methods§

Source

fn handle( &self, query: &[u8], peer: SocketAddr, protocol: Protocol, response: &mut Vec<u8>, ) -> impl Future<Output = Action> + Send

Provided Methods§

Source

fn udp_workers(&self) -> usize

Number of UDP worker sockets for this Listener.

Source

fn parallel_query( &self, _query: &[u8], _peer: SocketAddr, ) -> Option<Receiver<bool>>

Whether this HINFO Query must run concurrently with UDP reception.

Source

fn handle_shared( self: &Arc<Self>, query: &[u8], peer: SocketAddr, protocol: Protocol, response: &mut Vec<u8>, ) -> impl Future<Output = Action> + Send

Handle a Query while retaining access to the Listener’s owned state.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl<C: Chain> Handler for Server<C>