From e15020bd12e66bcf1b6880c9204a7577973f2989 Mon Sep 17 00:00:00 2001 From: Piotr Dulikowski Date: Thu, 5 Oct 2023 16:05:19 +0200 Subject: [PATCH] Revert "Merge pull request #819 from Lorak-mmk/add_serialization_traits" This reverts commit b51ac0682cfcf1307e6407e257c6915be2dbdd39, reversing changes made to 07b262c138324e7a24ba04b5cc2e79d6bb8a1d85. --- scylla-cql/src/lib.rs | 2 - scylla-cql/src/types/mod.rs | 1 - scylla-cql/src/types/serialize/mod.rs | 6 --- scylla-cql/src/types/serialize/row.rs | 49 ------------------------- scylla-cql/src/types/serialize/value.rs | 22 ----------- 5 files changed, 80 deletions(-) delete mode 100644 scylla-cql/src/types/mod.rs delete mode 100644 scylla-cql/src/types/serialize/mod.rs delete mode 100644 scylla-cql/src/types/serialize/row.rs delete mode 100644 scylla-cql/src/types/serialize/value.rs diff --git a/scylla-cql/src/lib.rs b/scylla-cql/src/lib.rs index b8d7d28671..47b58b4f4e 100644 --- a/scylla-cql/src/lib.rs +++ b/scylla-cql/src/lib.rs @@ -3,8 +3,6 @@ pub mod frame; #[macro_use] pub mod macros; -pub mod types; - pub use crate::frame::response::cql_to_rust; pub use crate::frame::response::cql_to_rust::FromRow; diff --git a/scylla-cql/src/types/mod.rs b/scylla-cql/src/types/mod.rs deleted file mode 100644 index ec9942a885..0000000000 --- a/scylla-cql/src/types/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod serialize; diff --git a/scylla-cql/src/types/serialize/mod.rs b/scylla-cql/src/types/serialize/mod.rs deleted file mode 100644 index 0cda84e252..0000000000 --- a/scylla-cql/src/types/serialize/mod.rs +++ /dev/null @@ -1,6 +0,0 @@ -use std::{any::Any, sync::Arc}; - -pub mod row; -pub mod value; - -type SerializationError = Arc; diff --git a/scylla-cql/src/types/serialize/row.rs b/scylla-cql/src/types/serialize/row.rs deleted file mode 100644 index 2e9832412d..0000000000 --- a/scylla-cql/src/types/serialize/row.rs +++ /dev/null @@ -1,49 +0,0 @@ -use std::sync::Arc; - -use crate::frame::response::result::ColumnSpec; -use crate::frame::value::ValueList; - -use super::SerializationError; - -pub struct RowSerializationContext<'a> { - columns: &'a [ColumnSpec], -} - -impl<'a> RowSerializationContext<'a> { - #[inline] - pub fn columns(&self) -> &'a [ColumnSpec] { - self.columns - } - - // TODO: change RowSerializationContext to make this faster - #[inline] - pub fn column_by_name(&self, target: &str) -> Option<&ColumnSpec> { - self.columns.iter().find(|&c| c.name == target) - } -} - -pub trait SerializeRow { - fn preliminary_type_check(ctx: &RowSerializationContext<'_>) -> Result<(), SerializationError>; - fn serialize( - &self, - ctx: &RowSerializationContext<'_>, - out: &mut Vec, - ) -> Result<(), SerializationError>; -} - -impl SerializeRow for T { - fn preliminary_type_check( - _ctx: &RowSerializationContext<'_>, - ) -> Result<(), SerializationError> { - Ok(()) - } - - fn serialize( - &self, - _ctx: &RowSerializationContext<'_>, - out: &mut Vec, - ) -> Result<(), SerializationError> { - self.write_to_request(out) - .map_err(|err| Arc::new(err) as SerializationError) - } -} diff --git a/scylla-cql/src/types/serialize/value.rs b/scylla-cql/src/types/serialize/value.rs deleted file mode 100644 index 43eb9ef738..0000000000 --- a/scylla-cql/src/types/serialize/value.rs +++ /dev/null @@ -1,22 +0,0 @@ -use std::sync::Arc; - -use crate::frame::response::result::ColumnType; -use crate::frame::value::Value; - -use super::SerializationError; - -pub trait SerializeCql { - fn preliminary_type_check(typ: &ColumnType) -> Result<(), SerializationError>; - fn serialize(&self, typ: &ColumnType, buf: &mut Vec) -> Result<(), SerializationError>; -} - -impl SerializeCql for T { - fn preliminary_type_check(_typ: &ColumnType) -> Result<(), SerializationError> { - Ok(()) - } - - fn serialize(&self, _typ: &ColumnType, buf: &mut Vec) -> Result<(), SerializationError> { - self.serialize(buf) - .map_err(|err| Arc::new(err) as SerializationError) - } -}