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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
use crate::*;
#[derive(
Debug, Clone, PartialEq, Deref, AsRef, From, Into, serde::Serialize, serde::Deserialize,
)]
pub struct ChannelData(#[serde(with = "serde_bytes")] pub Vec<u8>);
#[derive(Debug, Clone, PartialEq, PartialOrd, Hash, serde::Serialize, serde::Deserialize)]
pub struct WireUrl(String);
impl WireUrl {
pub fn to_url(&self) -> ProxyUrl {
self.into()
}
pub fn into_url(self) -> ProxyUrl {
self.into()
}
}
macro_rules! q_from {
($($t1:ty => $t2:ty, | $i:ident | {$e:expr},)*) => {$(
impl From<$t1> for $t2 {
fn from($i: $t1) -> Self {
$e
}
}
)*};
}
q_from! {
String => WireUrl, |s| { Self(s) },
&String => WireUrl, |s| { Self(s.to_string()) },
&str => WireUrl, |s| { Self(s.to_string()) },
ProxyUrl => WireUrl, |url| { Self(url.to_string()) },
&ProxyUrl => WireUrl, |url| { Self(url.to_string()) },
WireUrl => ProxyUrl, |url| { url.0.into() },
&WireUrl => ProxyUrl, |url| { (&url.0).into() },
}
kitsune_p2p_types::write_codec_enum! {
codec ProxyWire {
Failure(0x02) {
reason.0: String,
},
ReqProxy(0x10) {
cert_digest.0: ChannelData,
},
ReqProxyOk(0x11) {
proxy_url.0: WireUrl,
},
ChanNew(0x20) {
proxy_url.0: WireUrl,
},
ChanSend(0x30) {
channel_data.0: ChannelData,
},
}
}