Trait Handler

Source
pub trait Handler:
    Clone
    + Send
    + 'static {
    type PublicKey: PublicKey;
    type Request: Committable + Digestible + Codec;
    type Response: Committable<Commitment = <Self::Request as Committable>::Commitment> + Digestible<Digest = <Self::Request as Digestible>::Digest> + Codec;

    // Required method
    fn process(
        &mut self,
        origin: Self::PublicKey,
        request: Self::Request,
        response: Sender<Self::Response>,
    ) -> impl Future<Output = ()> + Send;
}
Expand description

A Handler receives requests and (optionally) sends replies.

Required Associated Types§

Source

type PublicKey: PublicKey

The PublicKey of the Originator.

Source

type Request: Committable + Digestible + Codec

The type of request received.

Source

type Response: Committable<Commitment = <Self::Request as Committable>::Commitment> + Digestible<Digest = <Self::Request as Digestible>::Digest> + Codec

The type of response to send.

Required Methods§

Source

fn process( &mut self, origin: Self::PublicKey, request: Self::Request, response: Sender<Self::Response>, ) -> impl Future<Output = ()> + Send

Processes a request from an Originator and (optionally) send a response.

If no response is needed, the responder should be dropped.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§