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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
use crate::record::SignedActionHashed;
use crate::ChainTopOrdering;
use holo_hash::ActionHash;
use holochain_integrity_types::ZomeId;
use holochain_serialized_bytes::prelude::*;
pub use holochain_integrity_types::link::*;
#[derive(
Debug,
PartialOrd,
Ord,
Clone,
Hash,
serde::Serialize,
serde::Deserialize,
PartialEq,
Eq,
SerializedBytes,
)]
pub struct Link {
pub target: holo_hash::AnyLinkableHash,
pub timestamp: crate::Timestamp,
pub tag: LinkTag,
pub create_link_hash: ActionHash,
}
#[derive(PartialEq, Clone, Debug, Serialize, Deserialize)]
pub struct CreateLinkInput {
pub base_address: holo_hash::AnyLinkableHash,
pub target_address: holo_hash::AnyLinkableHash,
pub zome_id: ZomeId,
pub link_type: LinkType,
pub tag: LinkTag,
pub chain_top_ordering: ChainTopOrdering,
}
impl CreateLinkInput {
pub fn new(
base_address: holo_hash::AnyLinkableHash,
target_address: holo_hash::AnyLinkableHash,
zome_id: ZomeId,
link_type: LinkType,
tag: LinkTag,
chain_top_ordering: ChainTopOrdering,
) -> Self {
Self {
base_address,
target_address,
zome_id,
link_type,
tag,
chain_top_ordering,
}
}
}
#[derive(PartialEq, Clone, Debug, Serialize, Deserialize)]
pub struct DeleteLinkInput {
pub address: holo_hash::ActionHash,
pub chain_top_ordering: ChainTopOrdering,
}
impl DeleteLinkInput {
pub fn new(address: holo_hash::ActionHash, chain_top_ordering: ChainTopOrdering) -> Self {
Self {
address,
chain_top_ordering,
}
}
}
#[derive(PartialEq, Clone, Debug, Serialize, Deserialize)]
pub struct GetLinksInput {
pub base_address: holo_hash::AnyLinkableHash,
pub link_type: LinkTypeFilter,
pub tag_prefix: Option<crate::link::LinkTag>,
}
impl GetLinksInput {
pub fn new(
base_address: holo_hash::AnyLinkableHash,
link_type: LinkTypeFilter,
tag_prefix: Option<crate::link::LinkTag>,
) -> Self {
Self {
base_address,
link_type,
tag_prefix,
}
}
}
type CreateLinkWithDeleteLinks = Vec<(SignedActionHashed, Vec<SignedActionHashed>)>;
#[derive(Clone, PartialEq, Debug, serde::Serialize, serde::Deserialize, SerializedBytes)]
pub struct LinkDetails(CreateLinkWithDeleteLinks);
impl From<CreateLinkWithDeleteLinks> for LinkDetails {
fn from(v: CreateLinkWithDeleteLinks) -> Self {
Self(v)
}
}
impl From<LinkDetails> for CreateLinkWithDeleteLinks {
fn from(link_details: LinkDetails) -> Self {
link_details.0
}
}
impl LinkDetails {
pub fn into_inner(self) -> CreateLinkWithDeleteLinks {
self.into()
}
}