Skip to main content

ServerRequestHandler

Trait ServerRequestHandler 

Source
pub trait ServerRequestHandler: Send + Sync {
    // Required method
    fn handle<'a>(
        &'a self,
        method: &'a str,
        params: &'a JsonObject,
    ) -> Pin<Box<dyn Future<Output = Result<JsonObject, HandlerRefusal>> + Send + 'a>>;
}
Expand description

Answers the requests a server sends the client.

§Examples

use std::pin::Pin;

use protocol_droid::application::client::handler::{HandlerRefusal, ServerRequestHandler};
use protocol_droid::domain::ir::JsonObject;

struct Decline;

impl ServerRequestHandler for Decline {
    fn handle<'a>(
        &'a self,
        method: &'a str,
        _params: &'a JsonObject,
    ) -> Pin<Box<dyn Future<Output = Result<JsonObject, HandlerRefusal>> + Send + 'a>> {
        Box::pin(async move { Err(HandlerRefusal::unsupported(method)) })
    }
}

Required Methods§

Source

fn handle<'a>( &'a self, method: &'a str, params: &'a JsonObject, ) -> Pin<Box<dyn Future<Output = Result<JsonObject, HandlerRefusal>> + Send + 'a>>

Answers one request with its result, or declines it.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§