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
use std::collections::HashMap; use std::convert::{TryFrom, TryInto}; use failure::Error; use crate::bolt; use crate::bolt::Value; use crate::error::ValueError; #[derive(Debug, Clone, Eq, PartialEq)] pub struct UnboundRelationship { pub(crate) rel_identity: i64, pub(crate) rel_type: String, pub(crate) properties: HashMap<String, Value>, } impl TryFrom<bolt::value::UnboundRelationship> for UnboundRelationship { type Error = Error; fn try_from(bolt_ub_rel: bolt::value::UnboundRelationship) -> Result<Self, Self::Error> { Ok(UnboundRelationship { rel_identity: i64::try_from(*bolt_ub_rel.rel_identity)?, rel_type: String::try_from(*bolt_ub_rel.rel_type)?, properties: (*bolt_ub_rel.properties).try_into()?, }) } } impl TryFrom<Value> for UnboundRelationship { type Error = Error; fn try_from(value: Value) -> Result<Self, Self::Error> { match value { Value::UnboundRelationship(ub_rel) => Ok(UnboundRelationship::try_from(ub_rel)?), _ => Err(ValueError::InvalidConversion(value).into()), } } }