use tetsy_jsonrpc_derive::rpc; use serde::{Serialize, Deserialize}; use std::sync::Arc; use tetsy_jsonrpc_core::Result; use tetsy_jsonrpc_pubsub::{typed::Subscriber, SubscriptionId, Session, PubSubHandler}; #[rpc] pub trait Rpc { type Metadata; /// Hello subscription #[pubsub(subscription = "hello", subscribe, name = "hello_subscribe", alias("hello_sub"))] fn subscribe(&self, _: Self::Metadata, _: Subscriber); /// Unsubscribe from hello subscription. #[pubsub(subscription = "hello", unsubscribe, name = "hello_unsubscribe")] fn unsubscribe(&self, a: Option, b: SubscriptionId) -> Result; } #[derive(Serialize, Deserialize)] struct SerializeAndDeserialize { foo: String, } struct RpcImpl; impl Rpc for RpcImpl { type Metadata = Arc; fn subscribe(&self, _: Self::Metadata, _: Subscriber) { unimplemented!(); } fn unsubscribe(&self, _: Option, _: SubscriptionId) -> Result { unimplemented!(); } } fn main() { let mut io = PubSubHandler::default(); let rpc = RpcImpl; io.extend_with(rpc.to_delegate()); }