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