From e2cbd2ce90e2611cf34cbfc86098f812c14ee7aa Mon Sep 17 00:00:00 2001 From: Allan Clements Date: Fri, 8 Nov 2024 19:46:40 -0600 Subject: [PATCH] Cleaned up loose ends --- gremlin-client/src/io/graph_binary_v1.rs | 51 ++----------------- gremlin-client/src/io/mod.rs | 11 ---- .../tests/graph_binary_read_write_cycle.rs | 35 ------------- 3 files changed, 3 insertions(+), 94 deletions(-) diff --git a/gremlin-client/src/io/graph_binary_v1.rs b/gremlin-client/src/io/graph_binary_v1.rs index 45c0720..cc48704 100644 --- a/gremlin-client/src/io/graph_binary_v1.rs +++ b/gremlin-client/src/io/graph_binary_v1.rs @@ -51,15 +51,10 @@ const POP: u8 = 0x1C; // const LAMBDA: u8 = 0x1D; const P: u8 = 0x1E; const SCOPE: u8 = 0x1F; -//TODO fill in others - -//... const T: u8 = 0x20; const TRAVERSER: u8 = 0x21; -//... const BOOLEAN: u8 = 0x27; const TEXTP: u8 = 0x28; -//... const MERGE: u8 = 0x2E; const UNSPECIFIED_NULL_OBEJECT: u8 = 0xFE; @@ -127,8 +122,7 @@ impl GraphBinaryV1Deser for ResponseMessage { .try_into() .expect("Status code should fit in i16"); //Status message is nullable - let status_message = String::from_be_bytes_nullable(bytes)? - .expect("TODO what to do with null status message"); + let status_message = String::from_be_bytes_nullable(bytes)?.unwrap_or_default(); let status_attributes = GraphBinaryV1Deser::from_be_bytes(bytes)?; let result_meta: HashMap = GraphBinaryV1Deser::from_be_bytes(bytes)?; @@ -571,9 +565,8 @@ pub trait GraphBinaryV1Deser: Sized { Some(VALUE_FLAG) => Self::from_be_bytes(bytes).map(Option::Some), Some(VALUE_NULL_FLAG) => Ok(None), other => { - let remainder: Vec = bytes.cloned().collect(); return Err(GremlinError::Cast(format!( - "Unexpected byte for nullable check: {other:?}. Remainder: {remainder:?}" + "Unexpected byte for nullable check: {other:?}" ))); } } @@ -708,8 +701,7 @@ impl GraphBinaryV1Deser for GValue { } } other => { - let remainder: Vec = bytes.cloned().collect(); - unimplemented!("TODO {other}. Remainder: {remainder:?}"); + unimplemented!("Unimplemented deserialization byte {other}"); } } } @@ -1049,43 +1041,6 @@ impl GraphBinaryV1Ser for &Uuid { } } -impl GraphBinaryV1Ser for &Vertex { - fn to_be_bytes(self, buf: &mut Vec) -> GremlinResult<()> { - //Format: {id}{label}{properties} - - //{id} is a fully qualified typed value composed of {type_code}{type_info}{value_flag}{value}. - self.id().to_be_bytes(buf)?; - - //{label} is a String value - self.label().to_be_bytes(buf)?; - - //{properties} is a fully qualified typed value composed of {type_code}{type_info}{value_flag}{value} which contains properties. - self.properties.len(); - todo!() - } -} - -impl GraphBinaryV1Ser for &VertexProperty { - fn to_be_bytes(self, buf: &mut Vec) -> GremlinResult<()> { - //Format: {id}{label}{value}{parent}{properties} - - //{id} is a fully qualified typed value composed of {type_code}{type_info}{value_flag}{value}. - self.id().to_be_bytes(buf)?; - - //{label} is a String value. - self.label().to_be_bytes(buf)?; - - //{value} is a fully qualified typed value composed of {type_code}{type_info}{value_flag}{value}. - //??????? - - //{parent} is a fully qualified typed value composed of {type_code}{type_info}{value_flag}{value} which contains the parent Vertex. Note that as TinkerPop currently send "references" only, this value will always be null.} - - //{properties} is a fully qualified typed value composed of {type_code}{type_info}{value_flag}{value} which contains properties. - - todo!() - } -} - impl GraphBinaryV1Ser for &GID { fn to_be_bytes(self, buf: &mut Vec) -> GremlinResult<()> { match self { diff --git a/gremlin-client/src/io/mod.rs b/gremlin-client/src/io/mod.rs index 4b59f61..926a8af 100644 --- a/gremlin-client/src/io/mod.rs +++ b/gremlin-client/src/io/mod.rs @@ -40,17 +40,6 @@ pub struct MiddleResponseResult { } impl IoProtocol { - pub fn read(&self, value: &Value) -> GremlinResult> { - if let Value::Null = value { - return Ok(None); - } - match self { - IoProtocol::GraphSONV2 => serializer_v2::deserializer_v2(value).map(Some), - IoProtocol::GraphSONV3 => serializer_v3::deserializer_v3(value).map(Some), - IoProtocol::GraphBinaryV1 => todo!(), - } - } - pub fn read_response(&self, response: Vec) -> GremlinResult { match self { IoProtocol::GraphSONV2 => { diff --git a/gremlin-client/tests/graph_binary_read_write_cycle.rs b/gremlin-client/tests/graph_binary_read_write_cycle.rs index fbdf6ce..4e782f7 100644 --- a/gremlin-client/tests/graph_binary_read_write_cycle.rs +++ b/gremlin-client/tests/graph_binary_read_write_cycle.rs @@ -37,38 +37,3 @@ fn simple_value_rw_cycle>(#[case] payload: T) { Some(payload) ) } - -// #[test] -// fn edge_rw_cycle() { -// todo!() -// } - -// #[test] -// fn path_rw_cycle() { -// todo!() -// } - -// #[test] -// fn property_rw_cycle() { -// todo!() -// } - -// #[test] -// fn vertex_rw_cycle() { -// todo!() -// } - -// #[test] -// fn vertex_property_rw_cycle() { -// todo!() -// } - -// #[test] -// fn scope_rw_cycle() { -// todo!() -// } - -// #[test] -// fn traverser_rw_cycle() { -// todo!() -// }