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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
use crate::header::ChainTopOrdering;
use holochain_integrity_types::EntryDefIndex;
use holochain_integrity_types::EntryVisibility;
use holochain_serialized_bytes::prelude::*;
mod app_entry_bytes;
pub use app_entry_bytes::*;
pub use holochain_integrity_types::entry::*;
#[derive(
Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, serde::Serialize, serde::Deserialize,
)]
pub enum EntryDefLocation {
App(EntryDefIndex),
CapClaim,
CapGrant,
}
#[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_location: EntryDefLocation,
pub entry_visibility: EntryVisibility,
pub entry: crate::entry::Entry,
pub chain_top_ordering: ChainTopOrdering,
}
impl CreateInput {
pub fn new(
entry_location: impl Into<EntryDefLocation>,
entry_visibility: EntryVisibility,
entry: crate::entry::Entry,
chain_top_ordering: ChainTopOrdering,
) -> Self {
Self {
entry_location: entry_location.into(),
entry_visibility,
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
}
}
#[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 entry: crate::entry::Entry,
pub chain_top_ordering: ChainTopOrdering,
}
#[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(),
}
}
}
impl EntryDefLocation {
pub fn app(entry_def_index: impl Into<EntryDefIndex>) -> Self {
Self::App(entry_def_index.into())
}
}
impl From<EntryDefIndex> for EntryDefLocation {
fn from(i: EntryDefIndex) -> Self {
EntryDefLocation::App(i)
}
}