karyon_jsonrpc/server/
pubsub_service.rs1use std::{future::Future, pin::Pin, sync::Arc};
2
3use crate::error::RPCResult;
4
5use super::channel::Channel;
6
7pub type PubSubRPCMethod<'a> =
9 Box<dyn Fn(Arc<Channel>, String, serde_json::Value) -> PubSubRPCMethodOutput<'a> + Send + 'a>;
10type PubSubRPCMethodOutput<'a> =
11 Pin<Box<dyn Future<Output = RPCResult<serde_json::Value>> + Send + Sync + 'a>>;
12
13pub trait PubSubRPCService: Sync + Send {
15 fn get_pubsub_method(&self, name: &str) -> Option<PubSubRPCMethod>;
16 fn name(&self) -> String;
17}