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
use crate::node_wrappers::{BaseNodeTrait, FinalNode};
use crate::tao::archetype::ArchetypeTrait;
use crate::tao::form::FormTrait;
use crate::tao::relation::attribute::{Owner, Value};
use crate::Wrapper;
pub trait AttributeTrait: FormTrait + Wrapper<BaseType = FinalNode> {
type OwnerForm: FormTrait + From<FinalNode>;
type ValueForm: FormTrait + From<FinalNode>;
fn set_owner(&mut self, owner: &Self::OwnerForm) {
self.essence_mut()
.add_outgoing(Owner::TYPE_ID, owner.essence());
}
fn owner(&self) -> Option<Self::OwnerForm> {
self.essence()
.outgoing_nodes(Owner::TYPE_ID)
.get(0)
.map(|n| Self::OwnerForm::from(*n))
}
fn set_value(&mut self, value: &Self::ValueForm) {
self.essence_mut()
.add_outgoing(Value::TYPE_ID, value.essence());
}
fn value(&self) -> Option<Self::ValueForm> {
self.essence()
.outgoing_nodes(Value::TYPE_ID)
.get(0)
.map(|n| Self::ValueForm::from(*n))
}
}