From bb0901a615d01eaadacbadc6426b874dbed445f9 Mon Sep 17 00:00:00 2001 From: Tglman Date: Thu, 24 Oct 2024 14:36:07 +0100 Subject: [PATCH] fix: completed support for server query in async --- .../src/asynchronous/network/decoder.rs | 38 ++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/orientdb-client/src/asynchronous/network/decoder.rs b/orientdb-client/src/asynchronous/network/decoder.rs index 6f5bd19..06c11bf 100644 --- a/orientdb-client/src/asynchronous/network/decoder.rs +++ b/orientdb-client/src/asynchronous/network/decoder.rs @@ -3,7 +3,8 @@ use crate::common::protocol::deserializer::DocumentDeserializer; use crate::common::protocol::messages::response::Response; use crate::common::protocol::messages::response::Status; use crate::common::protocol::messages::response::{ - Connect, CreateDB, DropDB, ExistDB, Header, LiveQuery, LiveQueryResult, Open, Query, QueryClose, + Connect, CreateDB, DropDB, ExistDB, Header, LiveQuery, LiveQueryResult, Open, Query, + QueryClose, ServerQuery, }; use crate::common::types::error::{OError, RequestError}; use crate::common::types::OResult; @@ -174,6 +175,36 @@ impl VersionedDecoder for Protocol37 { stats, )) } + + async fn decode_server_query(buf: &mut T) -> OrientResult + where + T: AsyncRead + Unpin + Send, + { + let query_id = reader::read_string(buf).await?; + let changes = reader::read_bool(buf).await?; + let has_plan = reader::read_bool(buf).await?; + + let execution_plan = if has_plan { + Some(read_result(buf).await?) + } else { + None + }; + + let _prefetched = reader::read_i32(buf).await?; + let records = read_result_set(buf).await?; + let has_next = reader::read_bool(buf).await?; + let stats = read_query_stats(buf).await?; + let _reaload_metadata = reader::read_bool(buf).await?; + + Ok(ServerQuery::new( + query_id, + changes, + execution_plan, + records, + has_next, + stats, + )) + } async fn decode_connect(buf: &mut T) -> OrientResult where T: AsyncRead + Unpin + Send, @@ -209,6 +240,10 @@ pub trait VersionedDecoder { where T: AsyncRead + Unpin + Send; + async fn decode_server_query(buf: &mut T) -> OrientResult + where + T: AsyncRead + Unpin + Send; + async fn decode_live_query(buf: &mut T) -> OrientResult where T: AsyncRead + Unpin + Send; @@ -259,6 +294,7 @@ where 4 => T::decode_create_db(buf).await?.into(), 6 => T::decode_exist(buf).await?.into(), 7 => T::decode_drop_db(buf).await?.into(), + 50 => T::decode_server_query(buf).await?.into(), 45 => T::decode_query(buf).await?.into(), 46 => T::decode_query_close(buf).await?.into(), 47 => T::decode_query(buf).await?.into(),