Skip to content

Commit

Permalink
frame/value: deprecate SerializeValuesError
Browse files Browse the repository at this point in the history
This is part of the legacy serialization framework.
  • Loading branch information
wprzytula committed Dec 11, 2024
1 parent 04c6f31 commit 59eb5c1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 22 deletions.
40 changes: 18 additions & 22 deletions scylla-cql/src/frame/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,10 @@ use super::response::result::CqlValue;
use super::types::vint_encode;
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")]
TooManyValues,
#[error("Mixing named and not named values is not allowed")]
MixingNamedAndNotNamedValues,
#[error(transparent)]
ValueTooBig(#[from] ValueTooBig),
#[error("Parsing serialized values failed")]
ParseError,
}

/// Represents an unset value
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
pub struct Unset;
Expand Down Expand Up @@ -684,6 +663,22 @@ mod legacy {
fn serialize(&self, buf: &mut Vec<u8>) -> Result<(), ValueTooBig>;
}

#[derive(Debug, Error, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
#[error("Value too big to be sent in a request - max 2GiB allowed")]
pub struct ValueTooBig;

#[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")]
TooManyValues,
#[error("Mixing named and not named values is not allowed")]
MixingNamedAndNotNamedValues,
#[error(transparent)]
ValueTooBig(#[from] ValueTooBig),
#[error("Parsing serialized values failed")]
ParseError,
}

/// Keeps a buffer with serialized Values
/// Allows adding new Values and iterating over serialized ones
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
Expand Down Expand Up @@ -1887,5 +1882,6 @@ mod legacy {
pub use legacy::{
LegacyBatchValues, LegacyBatchValuesFirstSerialized, LegacyBatchValuesFromIter,
LegacyBatchValuesIterator, LegacyBatchValuesIteratorFromIterator, LegacySerializedValues,
LegacySerializedValuesIterator, SerializedResult, TupleValuesIter, Value, ValueList,
LegacySerializedValuesIterator, SerializeValuesError, SerializedResult, TupleValuesIter, Value,
ValueList, ValueTooBig,
};
7 changes: 7 additions & 0 deletions scylla/src/transport/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use std::{
sync::Arc,
};

#[allow(deprecated)]
use scylla_cql::{
frame::{
frame_errors::{
Expand Down Expand Up @@ -124,6 +125,7 @@ pub enum QueryError {
IntoLegacyQueryResultError(#[from] IntoLegacyQueryResultError),
}

#[allow(deprecated)]
impl From<SerializeValuesError> for QueryError {
fn from(serialized_err: SerializeValuesError) -> QueryError {
QueryError::BadQuery(BadQuery::SerializeValuesError(serialized_err))
Expand Down Expand Up @@ -573,7 +575,12 @@ pub enum ViewsMetadataError {
#[non_exhaustive]
pub enum BadQuery {
/// Failed to serialize values passed to a query - values too big
#[deprecated(
since = "0.15.1",
note = "Legacy serialization API is not type-safe and is going to be removed soon"
)]
#[error("Serializing values failed: {0} ")]
#[allow(deprecated)]
SerializeValuesError(#[from] SerializeValuesError),

#[error("Serializing values failed: {0} ")]
Expand Down

0 comments on commit 59eb5c1

Please sign in to comment.