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
use crate::errors::AtomicResult;
use crate::storelike::Property;
use crate::values::Value;
use serde::Serialize;
#[derive(Clone, Debug, Serialize)]
pub struct Atom {
pub subject: String,
pub property: String,
pub value: String,
}
impl Atom {
pub fn new(subject: String, property: String, value: String) -> Self {
Atom {
subject,
property,
value,
}
}
}
#[derive(Clone, Debug, Serialize)]
pub struct RichAtom {
pub subject: String,
pub property: Property,
pub value: String,
pub native_value: Value,
}
impl RichAtom {
pub fn new(subject: String, property: Property, value: String) -> AtomicResult<Self> {
Ok(RichAtom {
subject,
property: property.clone(),
value: value.clone(),
native_value: Value::new(&value, &property.data_type)?,
})
}
}
impl From<RichAtom> for Atom {
fn from(richatom: RichAtom) -> Self {
Atom::new(
richatom.subject,
richatom.property.subject,
richatom.value,
)
}
}