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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
use crate::header::ChainTopOrdering;
use holochain_serialized_bytes::prelude::*;
mod app_entry_bytes;
pub use app_entry_bytes::*;
pub use holochain_integrity_types::entry::*;
#[derive(PartialEq, Debug, Clone, Serialize, Deserialize)]
pub struct GetOptions {
pub strategy: GetStrategy,
}
impl GetOptions {
pub fn latest() -> Self {
Self {
strategy: GetStrategy::Latest,
}
}
pub fn content() -> Self {
Self {
strategy: GetStrategy::Content,
}
}
}
impl Default for GetOptions {
fn default() -> Self {
Self::latest()
}
}
#[derive(PartialEq, Debug, Clone, Copy, Serialize, Deserialize)]
pub enum GetStrategy {
Latest,
Content,
}
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize, SerializedBytes)]
pub struct CreateInput {
pub entry_def_id: crate::entry_def::EntryDefId,
pub entry: crate::entry::Entry,
pub chain_top_ordering: ChainTopOrdering,
}
impl CreateInput {
pub fn new(
entry_def_id: crate::entry_def::EntryDefId,
entry: crate::entry::Entry,
chain_top_ordering: ChainTopOrdering,
) -> Self {
Self {
entry_def_id,
entry,
chain_top_ordering,
}
}
pub fn into_entry(self) -> Entry {
self.entry
}
pub fn chain_top_ordering(&self) -> &ChainTopOrdering {
&self.chain_top_ordering
}
}
impl AsRef<crate::Entry> for CreateInput {
fn as_ref(&self) -> &crate::Entry {
&self.entry
}
}
impl AsRef<crate::EntryDefId> for CreateInput {
fn as_ref(&self) -> &crate::EntryDefId {
&self.entry_def_id
}
}
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
pub struct GetInput {
pub any_dht_hash: holo_hash::AnyDhtHash,
pub get_options: crate::entry::GetOptions,
}
impl GetInput {
pub fn new(any_dht_hash: holo_hash::AnyDhtHash, get_options: crate::entry::GetOptions) -> Self {
Self {
any_dht_hash,
get_options,
}
}
}
#[derive(PartialEq, Debug, Deserialize, Serialize, Clone)]
pub struct UpdateInput {
pub original_header_address: holo_hash::HeaderHash,
pub create_input: CreateInput,
}
impl UpdateInput {
pub fn new(original_header_address: holo_hash::HeaderHash, create_input: CreateInput) -> Self {
Self {
original_header_address,
create_input,
}
}
}
#[derive(PartialEq, Debug, Deserialize, Serialize, Clone)]
pub struct DeleteInput {
pub deletes_header_hash: holo_hash::HeaderHash,
pub chain_top_ordering: ChainTopOrdering,
}
impl DeleteInput {
pub fn new(
deletes_header_hash: holo_hash::HeaderHash,
chain_top_ordering: ChainTopOrdering,
) -> Self {
Self {
deletes_header_hash,
chain_top_ordering,
}
}
}
impl From<holo_hash::HeaderHash> for DeleteInput {
fn from(deletes_header_hash: holo_hash::HeaderHash) -> Self {
Self {
deletes_header_hash,
chain_top_ordering: ChainTopOrdering::default(),
}
}
}