iroh_rpc_types/
gateway.rs1use derive_more::{From, TryInto};
2use quic_rpc::{
3 message::{Msg, RpcMsg, ServerStreaming},
4 Service,
5};
6use serde::{Deserialize, Serialize};
7
8use crate::{RpcResult, VersionRequest, VersionResponse, WatchRequest, WatchResponse};
9
10pub type GatewayAddr = crate::addr::Addr<GatewayService>;
12
13#[derive(Serialize, Deserialize, Debug, From, TryInto)]
14pub enum GatewayRequest {
15 Watch(WatchRequest),
16 Version(VersionRequest),
17}
18
19#[derive(Serialize, Deserialize, Debug, From, TryInto)]
20pub enum GatewayResponse {
21 Watch(WatchResponse),
22 Version(VersionResponse),
23 UnitResult(RpcResult<()>),
24}
25
26#[derive(Debug, Clone, Copy)]
27pub struct GatewayService;
28
29impl Service for GatewayService {
30 type Req = GatewayRequest;
31 type Res = GatewayResponse;
32}
33
34impl RpcMsg<GatewayService> for VersionRequest {
35 type Response = VersionResponse;
36}
37
38impl Msg<GatewayService> for WatchRequest {
39 type Response = WatchResponse;
40
41 type Update = Self;
42
43 type Pattern = ServerStreaming;
44}