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
use holochain_serialized_bytes::prelude::*;
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialEq,
Eq,
PartialOrd,
Ord,
serde::Serialize,
serde::Deserialize,
SerializedBytes,
)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
pub struct LinkType(pub u8);
impl LinkType {
pub fn new(u: u8) -> Self {
Self(u)
}
pub fn into_inner(self) -> u8 {
self.0
}
}
#[derive(
Debug,
PartialOrd,
Ord,
Clone,
Hash,
serde::Serialize,
serde::Deserialize,
PartialEq,
Eq,
SerializedBytes,
)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
pub struct LinkTag(#[serde(with = "serde_bytes")] pub Vec<u8>);
impl LinkTag {
pub fn new<T>(t: T) -> Self
where
T: Into<Vec<u8>>,
{
Self(t.into())
}
pub fn into_inner(self) -> Vec<u8> {
self.0
}
}
impl From<Vec<u8>> for LinkTag {
fn from(b: Vec<u8>) -> Self {
Self(b)
}
}
impl From<()> for LinkTag {
fn from(_: ()) -> Self {
Self(Vec::new())
}
}
impl AsRef<Vec<u8>> for LinkTag {
fn as_ref(&self) -> &Vec<u8> {
&self.0
}
}