ngrok/internals/
rpc.rs

1use std::fmt::Debug;
2
3use muxado::typed::StreamType;
4use serde::{
5    de::DeserializeOwned,
6    Serialize,
7};
8
9pub trait RpcRequest: Serialize + Debug {
10    type Response: DeserializeOwned + Debug;
11    const TYPE: StreamType;
12}
13
14macro_rules! rpc_req {
15    ($req:ty, $resp:ty, $typ:expr; $($t:tt)*) => {
16        impl <$($t)*> $crate::internals::rpc::RpcRequest for $req
17        {
18            type Response = $resp;
19            const TYPE: StreamType = $typ;
20        }
21    };
22    ($req:ty, $resp:ty, $typ:expr) => {
23        impl $crate::internals::rpc::RpcRequest for $req {
24            type Response = $resp;
25            const TYPE: StreamType = $typ;
26        }
27    };
28}