dpp/document/accessors/
mod.rs

1pub(crate) mod v0;
2
3pub use v0::*;
4
5use crate::document::Document;
6use crate::identity::TimestampMillis;
7use crate::prelude::{BlockHeight, CoreBlockHeight, Revision};
8use platform_value::{Identifier, Value};
9use std::collections::BTreeMap;
10
11impl DocumentV0Getters for Document {
12    fn id(&self) -> Identifier {
13        match self {
14            Document::V0(v0) => v0.id,
15        }
16    }
17
18    fn id_ref(&self) -> &Identifier {
19        match self {
20            Document::V0(v0) => &v0.id,
21        }
22    }
23
24    fn owner_id(&self) -> Identifier {
25        match self {
26            Document::V0(v0) => v0.owner_id,
27        }
28    }
29
30    fn owner_id_ref(&self) -> &Identifier {
31        match self {
32            Document::V0(v0) => &v0.owner_id,
33        }
34    }
35
36    fn properties(&self) -> &BTreeMap<String, Value> {
37        match self {
38            Document::V0(v0) => &v0.properties,
39        }
40    }
41
42    fn properties_mut(&mut self) -> &mut BTreeMap<String, Value> {
43        match self {
44            Document::V0(v0) => &mut v0.properties,
45        }
46    }
47
48    fn properties_consumed(self) -> BTreeMap<String, Value> {
49        match self {
50            Document::V0(v0) => v0.properties,
51        }
52    }
53
54    fn revision(&self) -> Option<Revision> {
55        match self {
56            Document::V0(v0) => v0.revision,
57        }
58    }
59
60    fn created_at(&self) -> Option<TimestampMillis> {
61        match self {
62            Document::V0(v0) => v0.created_at,
63        }
64    }
65
66    fn updated_at(&self) -> Option<TimestampMillis> {
67        match self {
68            Document::V0(v0) => v0.updated_at,
69        }
70    }
71
72    fn transferred_at(&self) -> Option<TimestampMillis> {
73        match self {
74            Document::V0(v0) => v0.transferred_at,
75        }
76    }
77
78    fn created_at_block_height(&self) -> Option<BlockHeight> {
79        match self {
80            Document::V0(v0) => v0.created_at_block_height,
81        }
82    }
83
84    fn updated_at_block_height(&self) -> Option<BlockHeight> {
85        match self {
86            Document::V0(v0) => v0.updated_at_block_height,
87        }
88    }
89
90    fn transferred_at_block_height(&self) -> Option<BlockHeight> {
91        match self {
92            Document::V0(v0) => v0.transferred_at_block_height,
93        }
94    }
95
96    fn created_at_core_block_height(&self) -> Option<CoreBlockHeight> {
97        match self {
98            Document::V0(v0) => v0.created_at_core_block_height,
99        }
100    }
101
102    fn updated_at_core_block_height(&self) -> Option<CoreBlockHeight> {
103        match self {
104            Document::V0(v0) => v0.updated_at_core_block_height,
105        }
106    }
107
108    fn transferred_at_core_block_height(&self) -> Option<CoreBlockHeight> {
109        match self {
110            Document::V0(v0) => v0.transferred_at_core_block_height,
111        }
112    }
113
114    fn creator_id(&self) -> Option<Identifier> {
115        match self {
116            Document::V0(v0) => v0.creator_id,
117        }
118    }
119}
120
121impl DocumentV0Setters for Document {
122    fn set_id(&mut self, id: Identifier) {
123        match self {
124            Document::V0(v0) => v0.id = id,
125        }
126    }
127
128    fn set_owner_id(&mut self, owner_id: Identifier) {
129        match self {
130            Document::V0(v0) => v0.owner_id = owner_id,
131        }
132    }
133
134    fn set_properties(&mut self, properties: BTreeMap<String, Value>) {
135        match self {
136            Document::V0(v0) => v0.properties = properties,
137        }
138    }
139
140    fn set_revision(&mut self, revision: Option<Revision>) {
141        match self {
142            Document::V0(v0) => v0.revision = revision,
143        }
144    }
145
146    fn bump_revision(&mut self) {
147        match self {
148            Document::V0(v0) => v0.bump_revision(),
149        }
150    }
151
152    fn set_created_at(&mut self, created_at: Option<TimestampMillis>) {
153        match self {
154            Document::V0(v0) => v0.created_at = created_at,
155        }
156    }
157
158    fn set_updated_at(&mut self, updated_at: Option<TimestampMillis>) {
159        match self {
160            Document::V0(v0) => v0.updated_at = updated_at,
161        }
162    }
163
164    fn set_transferred_at(&mut self, transferred_at: Option<TimestampMillis>) {
165        match self {
166            Document::V0(v0) => v0.transferred_at = transferred_at,
167        }
168    }
169
170    fn set_created_at_block_height(&mut self, created_at_block_height: Option<u64>) {
171        match self {
172            Document::V0(v0) => v0.created_at_block_height = created_at_block_height,
173        }
174    }
175
176    fn set_updated_at_block_height(&mut self, updated_at_block_height: Option<u64>) {
177        match self {
178            Document::V0(v0) => v0.updated_at_block_height = updated_at_block_height,
179        }
180    }
181
182    fn set_transferred_at_block_height(&mut self, transferred_at_block_height: Option<u64>) {
183        match self {
184            Document::V0(v0) => v0.transferred_at_block_height = transferred_at_block_height,
185        }
186    }
187
188    fn set_created_at_core_block_height(&mut self, created_at_core_block_height: Option<u32>) {
189        match self {
190            Document::V0(v0) => v0.created_at_core_block_height = created_at_core_block_height,
191        }
192    }
193
194    fn set_updated_at_core_block_height(&mut self, updated_at_core_block_height: Option<u32>) {
195        match self {
196            Document::V0(v0) => v0.updated_at_core_block_height = updated_at_core_block_height,
197        }
198    }
199
200    fn set_transferred_at_core_block_height(
201        &mut self,
202        transferred_at_core_block_height: Option<u32>,
203    ) {
204        match self {
205            Document::V0(v0) => {
206                v0.transferred_at_core_block_height = transferred_at_core_block_height
207            }
208        }
209    }
210
211    fn set_creator_id(&mut self, creator_id: Option<Identifier>) {
212        match self {
213            Document::V0(v0) => v0.creator_id = creator_id,
214        }
215    }
216}