aboutsummaryrefslogtreecommitdiff
path: root/jsonrpc/src/server/service.rs
blob: 5195d2c7ad3bf6ac49e99444d9a5a2bae5c5e6b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use std::{future::Future, pin::Pin};

use crate::RPCResult;

/// Represents the RPC method
pub type RPCMethod<'a> = Box<dyn Fn(serde_json::Value) -> RPCMethodOutput<'a> + Send + 'a>;
type RPCMethodOutput<'a> =
    Pin<Box<dyn Future<Output = RPCResult<serde_json::Value>> + Send + Sync + 'a>>;

/// Defines the interface for an RPC service.
pub trait RPCService: Sync + Send {
    fn get_method(&self, name: &str) -> Option<RPCMethod>;
    fn name(&self) -> String;
}