iroh_rpc_types/
gateway.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use derive_more::{From, TryInto};
use quic_rpc::{
    message::{Msg, RpcMsg, ServerStreaming},
    Service,
};
use serde::{Deserialize, Serialize};

use crate::{RpcResult, VersionRequest, VersionResponse, WatchRequest, WatchResponse};

/// Gateway address
pub type GatewayAddr = crate::addr::Addr<GatewayService>;

#[derive(Serialize, Deserialize, Debug, From, TryInto)]
pub enum GatewayRequest {
    Watch(WatchRequest),
    Version(VersionRequest),
}

#[derive(Serialize, Deserialize, Debug, From, TryInto)]
pub enum GatewayResponse {
    Watch(WatchResponse),
    Version(VersionResponse),
    UnitResult(RpcResult<()>),
}

#[derive(Debug, Clone, Copy)]
pub struct GatewayService;

impl Service for GatewayService {
    type Req = GatewayRequest;
    type Res = GatewayResponse;
}

impl RpcMsg<GatewayService> for VersionRequest {
    type Response = VersionResponse;
}

impl Msg<GatewayService> for WatchRequest {
    type Response = WatchResponse;

    type Update = Self;

    type Pattern = ServerStreaming;
}