From c1362553751f7f0b8a93f16f61f0a3ef75becc59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Przytu=C5=82a?= Date: Fri, 6 Dec 2024 10:39:32 +0100 Subject: [PATCH] codewide: deprecate legacy serialization API's items Items constituting the legacy serialization API hadn't been marked with the #[deprecated] attribute. As we're going to remove them soon, let's warn users about that explicitly. --- scylla-cql/src/frame/response/result.rs | 1 + scylla-cql/src/frame/value.rs | 12 ++++++++++ scylla-cql/src/frame/value_tests.rs | 3 +++ scylla-cql/src/lib.rs | 3 +++ scylla-cql/src/types/serialize/batch.rs | 11 +++++++++ scylla-cql/src/types/serialize/row.rs | 30 +++++++++++++++++++++++-- scylla-cql/src/types/serialize/value.rs | 24 ++++++++++++++++++++ scylla/src/lib.rs | 3 +++ scylla/src/macros.rs | 11 +++++++++ 9 files changed, 96 insertions(+), 2 deletions(-) diff --git a/scylla-cql/src/frame/response/result.rs b/scylla-cql/src/frame/response/result.rs index 2c5a76e29c..39bf0730cb 100644 --- a/scylla-cql/src/frame/response/result.rs +++ b/scylla-cql/src/frame/response/result.rs @@ -2475,6 +2475,7 @@ mod tests { ); } + #[allow(deprecated)] #[test] fn test_serialize_empty() { use crate::frame::value::Value; diff --git a/scylla-cql/src/frame/value.rs b/scylla-cql/src/frame/value.rs index d02c34599b..0db6f503ad 100644 --- a/scylla-cql/src/frame/value.rs +++ b/scylla-cql/src/frame/value.rs @@ -14,12 +14,17 @@ use super::types::RawValue; #[derive(Debug, Error, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] #[error("Value too big to be sent in a request - max 2GiB allowed")] +#[deprecated( + since = "0.15.1", + note = "Legacy serialization API is not type-safe and is going to be removed soon" +)] pub struct ValueTooBig; #[derive(Debug, Error, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] #[error("Value is too large to fit in the CQL type")] pub struct ValueOverflow; +#[allow(deprecated)] #[derive(Debug, Error, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] pub enum SerializeValuesError { #[error("Too many values to add, max 65,535 values can be sent in a request")] @@ -664,7 +669,13 @@ pub struct CqlDuration { pub nanoseconds: i64, } +#[deprecated( + since = "0.15.1", + note = "Legacy serialization API is not type-safe and is going to be removed soon" +)] mod legacy { + #![allow(deprecated)] + use super::*; /// Every value being sent in a query must implement this trait @@ -1872,6 +1883,7 @@ mod legacy { } } } +#[allow(deprecated)] pub use legacy::{ LegacyBatchValues, LegacyBatchValuesFirstSerialized, LegacyBatchValuesFromIter, LegacyBatchValuesIterator, LegacyBatchValuesIteratorFromIterator, LegacySerializedValues, diff --git a/scylla-cql/src/frame/value_tests.rs b/scylla-cql/src/frame/value_tests.rs index 62d998cbf3..a2df53a4d1 100644 --- a/scylla-cql/src/frame/value_tests.rs +++ b/scylla-cql/src/frame/value_tests.rs @@ -1,3 +1,6 @@ +// TODO: remove this once deprecated items are deleted. +#![allow(deprecated)] + use crate::frame::value::{CqlTimeuuid, CqlVarint}; use crate::frame::{response::result::CqlValue, types::RawValue, value::LegacyBatchValuesIterator}; use crate::types::serialize::batch::{BatchValues, BatchValuesIterator, LegacyBatchValuesAdapter}; diff --git a/scylla-cql/src/lib.rs b/scylla-cql/src/lib.rs index 228fc43f89..09a4e56d70 100644 --- a/scylla-cql/src/lib.rs +++ b/scylla-cql/src/lib.rs @@ -16,7 +16,9 @@ pub mod macros { #[allow(deprecated)] pub use crate::impl_from_cql_value_from_method; + #[allow(deprecated)] pub use crate::impl_serialize_row_via_value_list; + #[allow(deprecated)] pub use crate::impl_serialize_value_via_value; } @@ -35,6 +37,7 @@ pub mod _macro_internal { FromCqlVal, FromCqlValError, FromRow, FromRowError, }; pub use crate::frame::response::result::{ColumnSpec, ColumnType, CqlValue, Row}; + #[allow(deprecated)] pub use crate::frame::value::{ LegacySerializedValues, SerializedResult, Value, ValueList, ValueTooBig, }; diff --git a/scylla-cql/src/types/serialize/batch.rs b/scylla-cql/src/types/serialize/batch.rs index cca0ec1b0e..aff43b990e 100644 --- a/scylla-cql/src/types/serialize/batch.rs +++ b/scylla-cql/src/types/serialize/batch.rs @@ -4,6 +4,7 @@ // Note: When editing above doc-comment edit the corresponding comment on // re-export module in scylla crate too. +#[allow(deprecated)] use crate::frame::value::{LegacyBatchValues, LegacyBatchValuesIterator}; use super::row::{RowSerializationContext, SerializeRow}; @@ -332,8 +333,13 @@ impl BatchValues for &T { /// Note that the [`LegacyBatchValues`] trait is deprecated and will be /// removed in the future, and you should prefer using [`BatchValues`] as it is /// more type-safe. +#[deprecated( + since = "0.15.1", + note = "Legacy serialization API is not type-safe and is going to be removed soon" +)] pub struct LegacyBatchValuesAdapter(pub T); +#[allow(deprecated)] impl BatchValues for LegacyBatchValuesAdapter where T: LegacyBatchValues, @@ -351,8 +357,13 @@ where /// A newtype wrapper which adjusts an existing types that implement /// [`LegacyBatchValuesIterator`] to the current [`BatchValuesIterator`] API. +#[deprecated( + since = "0.15.1", + note = "Legacy serialization API is not type-safe and is going to be removed soon" +)] pub struct LegacyBatchValuesIteratorAdapter(pub T); +#[allow(deprecated)] impl<'r, T> BatchValuesIterator<'r> for LegacyBatchValuesIteratorAdapter where T: LegacyBatchValuesIterator<'r>, diff --git a/scylla-cql/src/types/serialize/row.rs b/scylla-cql/src/types/serialize/row.rs index 665335ebe4..7478a0b9c3 100644 --- a/scylla-cql/src/types/serialize/row.rs +++ b/scylla-cql/src/types/serialize/row.rs @@ -16,8 +16,8 @@ use crate::frame::request::RequestDeserializationError; use crate::frame::response::result::ColumnType; use crate::frame::response::result::PreparedMetadata; use crate::frame::types; -use crate::frame::value::SerializeValuesError; -use crate::frame::value::{LegacySerializedValues, ValueList}; +#[allow(deprecated)] +use crate::frame::value::{LegacySerializedValues, SerializeValuesError, ValueList}; use crate::frame::{response::result::ColumnSpec, types::RawValue}; use super::value::SerializeValue; @@ -282,10 +282,12 @@ impl SerializeRow for &T { } } +#[allow(deprecated)] impl SerializeRow for LegacySerializedValues { fallback_impl_contents!(); } +#[allow(deprecated)] impl SerializeRow for Cow<'_, LegacySerializedValues> { fallback_impl_contents!(); } @@ -409,6 +411,10 @@ impl_tuples!( /// } /// impl_serialize_row_via_value_list!(WithGenerics); /// ``` +#[deprecated( + since = "0.15.1", + note = "Legacy serialization API is not type-safe and is going to be removed soon" +)] #[macro_export] macro_rules! impl_serialize_row_via_value_list { ($t:ident$(<$($targ:tt $(: $tbound:tt)?),*>)?) => { @@ -440,8 +446,13 @@ macro_rules! impl_serialize_row_via_value_list { /// /// See the [`impl_serialize_row_via_value_list`] macro on information about /// the properties of the [`SerializeRow`] implementation. +#[deprecated( + since = "0.15.1", + note = "Legacy serialization API is not type-safe and is going to be removed soon" +)] pub struct ValueListAdapter(pub T); +#[allow(deprecated)] impl SerializeRow for ValueListAdapter where T: ValueList, @@ -482,6 +493,11 @@ where /// /// See [`impl_serialize_row_via_value_list`] which generates a boilerplate /// [`SerializeRow`] implementation that uses this function. +#[deprecated( + since = "0.15.1", + note = "Legacy serialization API is not type-safe and is going to be removed soon" +)] +#[allow(deprecated)] pub fn serialize_legacy_row( r: &T, ctx: &RowSerializationContext<'_>, @@ -686,6 +702,11 @@ impl Display for BuiltinSerializationErrorKind { /// Describes a failure to translate the output of the [`ValueList`] legacy trait /// into an output of the [`SerializeRow`] trait. #[derive(Error, Debug)] +#[deprecated( + since = "0.15.1", + note = "Legacy serialization API is not type-safe and is going to be removed soon" +)] +#[allow(deprecated)] pub enum ValueListToSerializeRowAdapterError { /// The values generated by the [`ValueList`] trait were provided in /// name-value pairs, and there is a column in the statement for which @@ -921,7 +942,9 @@ pub(crate) mod tests { use crate::frame::response::result::{ColumnSpec, ColumnType, TableSpec}; use crate::frame::types::RawValue; + #[allow(deprecated)] use crate::frame::value::{LegacySerializedValues, MaybeUnset, SerializedResult, ValueList}; + #[allow(deprecated)] use crate::types::serialize::row::ValueListAdapter; use crate::types::serialize::{RowWriter, SerializationError}; @@ -938,6 +961,7 @@ pub(crate) mod tests { ColumnSpec::borrowed(name, typ, TableSpec::borrowed("ks", "tbl")) } + #[allow(deprecated)] #[test] fn test_legacy_fallback() { let row = ( @@ -967,6 +991,7 @@ pub(crate) mod tests { assert_eq!(&legacy_data[2..], new_data); } + #[allow(deprecated)] #[test] fn test_legacy_fallback_with_names() { let sorted_row = ( @@ -1056,6 +1081,7 @@ pub(crate) mod tests { ColumnSpec::borrowed(name, typ, TableSpec::borrowed("ks", "tbl")) } + #[allow(deprecated)] #[test] fn test_legacy_wrapper() { struct Foo; diff --git a/scylla-cql/src/types/serialize/value.rs b/scylla-cql/src/types/serialize/value.rs index 78e169aa4e..ce6cc19a0e 100644 --- a/scylla-cql/src/types/serialize/value.rs +++ b/scylla-cql/src/types/serialize/value.rs @@ -15,6 +15,7 @@ use uuid::Uuid; use crate::frame::response::result::{ColumnType, CqlValue}; use crate::frame::types::vint_encode; +#[allow(deprecated)] use crate::frame::value::{ Counter, CqlDate, CqlDecimal, CqlDuration, CqlTime, CqlTimestamp, CqlTimeuuid, CqlVarint, MaybeUnset, Unset, Value, @@ -926,6 +927,10 @@ fn serialize_mapping<'t, 'b, K: SerializeValue + 't, V: SerializeValue + 't>( /// } /// impl_serialize_value_via_value!(WithGenerics); /// ``` +#[deprecated( + since = "0.15.1", + note = "Legacy serialization API is not type-safe and is going to be removed soon" +)] #[macro_export] macro_rules! impl_serialize_value_via_value { ($t:ident$(<$($targ:tt $(: $tbound:tt)?),*>)?) => { @@ -952,8 +957,13 @@ macro_rules! impl_serialize_value_via_value { /// /// See the [`impl_serialize_value_via_value`] macro on information about /// the properties of the [`SerializeValue`] implementation. +#[deprecated( + since = "0.15.1", + note = "Legacy serialization API is not type-safe and is going to be removed soon" +)] pub struct ValueAdapter(pub T); +#[allow(deprecated)] impl SerializeValue for ValueAdapter where T: Value, @@ -981,6 +991,11 @@ where /// /// See [`impl_serialize_value_via_value`] which generates a boilerplate /// [`SerializeValue`] implementation that uses this function. +#[deprecated( + since = "0.15.1", + note = "Legacy serialization API is not type-safe and is going to be removed soon" +)] +#[allow(deprecated)] pub fn serialize_legacy_value<'b, T: Value>( v: &T, writer: CellWriter<'b>, @@ -1465,6 +1480,11 @@ impl Display for UdtSerializationErrorKind { /// Describes a failure to translate the output of the [`Value`] legacy trait /// into an output of the [`SerializeValue`] trait. +#[deprecated( + since = "0.15.1", + note = "Legacy serialization API is not type-safe and is going to be removed soon" +)] +#[allow(deprecated)] #[derive(Error, Debug)] pub enum ValueToSerializeValueAdapterError { /// The value is too bit to be serialized as it exceeds the maximum 2GB size limit. @@ -1598,7 +1618,9 @@ pub(crate) mod tests { use std::collections::BTreeMap; use crate::frame::response::result::{ColumnType, CqlValue}; + #[allow(deprecated)] use crate::frame::value::{Counter, MaybeUnset, Unset, Value, ValueTooBig}; + #[allow(deprecated)] use crate::types::serialize::value::{ BuiltinSerializationError, BuiltinSerializationErrorKind, BuiltinTypeCheckError, BuiltinTypeCheckErrorKind, MapSerializationErrorKind, MapTypeCheckErrorKind, @@ -1612,6 +1634,7 @@ pub(crate) mod tests { use super::{SerializeValue, UdtSerializationErrorKind, UdtTypeCheckErrorKind}; + #[allow(deprecated)] fn check_compat(v: V) { let mut legacy_data = Vec::new(); ::serialize(&v, &mut legacy_data).unwrap(); @@ -1662,6 +1685,7 @@ pub(crate) mod tests { do_serialize_result(t, typ).unwrap_err() } + #[allow(deprecated)] #[test] fn test_legacy_wrapper() { struct Foo; diff --git a/scylla/src/lib.rs b/scylla/src/lib.rs index 6724a65d9b..8dc56420a9 100644 --- a/scylla/src/lib.rs +++ b/scylla/src/lib.rs @@ -144,6 +144,7 @@ pub mod serialize { }; // Legacy migration types - to be removed when removing legacy framework + #[allow(deprecated)] pub use scylla_cql::types::serialize::batch::{ LegacyBatchValuesAdapter, LegacyBatchValuesIteratorAdapter, }; @@ -161,6 +162,7 @@ pub mod serialize { }; // Legacy migration types - to be removed when removing legacy framework + #[allow(deprecated)] pub use scylla_cql::types::serialize::row::{ // Legacy migration types - to be removed when removing legacy framework serialize_legacy_row, @@ -188,6 +190,7 @@ pub mod serialize { }; // Legacy migration types - to be removed when removing legacy framework + #[allow(deprecated)] pub use scylla_cql::types::serialize::value::{ serialize_legacy_value, ValueAdapter, ValueToSerializeValueAdapterError, }; diff --git a/scylla/src/macros.rs b/scylla/src/macros.rs index ce64153e80..3e75fa1ab1 100644 --- a/scylla/src/macros.rs +++ b/scylla/src/macros.rs @@ -30,6 +30,11 @@ pub use scylla_cql::macros::FromUserType; /// /// --- /// +#[deprecated( + since = "0.15.1", + note = "Legacy serialization API is not type-safe and is going to be removed soon" +)] +#[allow(deprecated)] pub use scylla_cql::macros::IntoUserType; /// Derive macro for the [`SerializeValue`](crate::serialize::value::SerializeValue) trait @@ -486,6 +491,10 @@ pub use scylla_macros::DeserializeRow; /// /// --- /// +#[deprecated( + since = "0.15.1", + note = "Legacy serialization API is not type-safe and is going to be removed soon" +)] pub use scylla_cql::macros::ValueList; #[deprecated( @@ -495,7 +504,9 @@ pub use scylla_cql::macros::ValueList; #[allow(deprecated)] pub use scylla_cql::macros::impl_from_cql_value_from_method; +#[allow(deprecated)] pub use scylla_cql::macros::impl_serialize_row_via_value_list; +#[allow(deprecated)] pub use scylla_cql::macros::impl_serialize_value_via_value; // Reexports for derive(IntoUserType)