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