packs/std_structs/
relationship.rs1use crate::*;
2use crate::std_structs::{StdStructPrimitive};
3
4#[derive(Debug, Clone, PartialEq, Pack, Unpack)]
5#[tag = 0x52]
6pub struct Relationship {
7 pub id: i64,
8 pub start_node_id: i64,
9 pub end_node_id: i64,
10 pub _type: String,
11 pub properties: Dictionary<StdStructPrimitive>
12}
13
14impl Relationship {
15 pub fn new(id: i64, _type: &str, from: i64, to: i64) -> Self {
16 Relationship {
17 id,
18 start_node_id: from,
19 end_node_id: to,
20 _type: String::from(_type),
21 properties: Dictionary::new(),
22 }
23 }
24}
25
26#[cfg(test)]
27pub mod test {
28 use crate::packable::test::pack_unpack_test;
29 use crate::Value;
30 use crate::std_structs::relationship::Relationship;
31
32 #[test]
33 fn pack_unpack() {
34 pack_unpack_test::<Relationship>(&[
35 Relationship {
36 id: 42,
37 start_node_id: 1,
38 end_node_id: 2,
39 _type: String::from("KNOWS"),
40 properties: vec![(String::from("foo"), Value::from(1))].into_iter().collect(),
41 }
42 ]);
43 }
44}