bolt_proto/value/
unbound_relationship.rs

1use std::collections::HashMap;
2
3use bolt_proto_derive::*;
4
5use crate::{value::SIGNATURE_UNBOUND_RELATIONSHIP, Value};
6
7#[bolt_structure(SIGNATURE_UNBOUND_RELATIONSHIP)]
8#[derive(Debug, Clone, Eq, PartialEq)]
9pub struct UnboundRelationship {
10    pub(crate) rel_identity: i64,
11    pub(crate) rel_type: String,
12    pub(crate) properties: HashMap<String, Value>,
13}
14
15impl UnboundRelationship {
16    pub fn new(
17        rel_identity: i64,
18        rel_type: String,
19        properties: HashMap<String, impl Into<Value>>,
20    ) -> Self {
21        Self {
22            rel_identity,
23            rel_type,
24            properties: properties.into_iter().map(|(k, v)| (k, v.into())).collect(),
25        }
26    }
27
28    pub fn rel_identity(&self) -> i64 {
29        self.rel_identity
30    }
31
32    pub fn rel_type(&self) -> &str {
33        &self.rel_type
34    }
35
36    pub fn properties(&self) -> &HashMap<String, Value> {
37        &self.properties
38    }
39}