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
use holochain_persistence_api::cas::content::Address;
use holochain_json_api::{error::JsonError, json::JsonString};
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Hash, Eq, DefaultJson)]
pub struct Provenance(pub Address, pub Signature);
impl Provenance {
pub fn new(source: Address, signature: Signature) -> Self {
Provenance(source, signature)
}
pub fn source(&self) -> Address {
self.0.clone()
}
pub fn signature(&self) -> Signature {
self.1.clone()
}
}
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Hash, Eq, DefaultJson)]
pub struct Signature(String);
impl Signature {
pub fn fake() -> Signature {
test_signature()
}
}
impl From<&'static str> for Signature {
fn from(s: &str) -> Signature {
Signature(s.to_owned())
}
}
impl From<String> for Signature {
fn from(s: String) -> Signature {
Signature(s)
}
}
pub fn test_signatures() -> Vec<Signature> {
vec![test_signature()]
}
pub fn test_signature() -> Signature {
Signature::from("fake-signature")
}
pub fn test_signature_b() -> Signature {
Signature::from("another-fake-signature")
}
pub fn test_signature_c() -> Signature {
Signature::from("sig-c")
}
impl From<Signature> for String {
fn from(s: Signature) -> String {
s.0
}
}