From e7778608e4155ba7f43f75668825bfcc2d957f22 Mon Sep 17 00:00:00 2001 From: muzarski Date: Wed, 7 Aug 2024 11:24:49 +0200 Subject: [PATCH] f_errors: remove TryFromInt variant from ParseError We removed last usages of this variant from scylla-proxy. This allows us to remove the variant. In the following commit, we will remove ParseError. --- scylla-cql/src/frame/frame_errors.rs | 5 +---- scylla-proxy/src/frame.rs | 11 +++++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/scylla-cql/src/frame/frame_errors.rs b/scylla-cql/src/frame/frame_errors.rs index 221896974d..9dc305a056 100644 --- a/scylla-cql/src/frame/frame_errors.rs +++ b/scylla-cql/src/frame/frame_errors.rs @@ -61,10 +61,7 @@ pub enum FrameSerializationError { } #[derive(Error, Debug)] -pub enum ParseError { - #[error(transparent)] - TryFromIntError(#[from] std::num::TryFromIntError), -} +pub enum ParseError {} #[non_exhaustive] #[derive(Error, Debug, Clone)] diff --git a/scylla-proxy/src/frame.rs b/scylla-proxy/src/frame.rs index fefefa3648..cac640c62f 100644 --- a/scylla-proxy/src/frame.rs +++ b/scylla-proxy/src/frame.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use bytes::{Buf, BufMut, Bytes, BytesMut}; -use scylla_cql::frame::frame_errors::{FrameDeserializationError, ParseError}; +use scylla_cql::frame::frame_errors::FrameDeserializationError; use scylla_cql::frame::protocol_features::ProtocolFeatures; pub use scylla_cql::frame::request::RequestOpcode; use scylla_cql::frame::request::{Request, RequestDeserializationError}; @@ -87,7 +87,7 @@ impl ResponseFrame { request_params: FrameParams, error: DbError, msg: Option<&str>, - ) -> Result { + ) -> Result { let msg = msg.unwrap_or("Proxy-triggered error."); let len_bytes = (msg.len() as u16).to_be_bytes(); // string len is a short in CQL protocol let code_bytes = error.code(&ProtocolFeatures::default()).to_be_bytes(); // TODO: configurable features @@ -111,7 +111,7 @@ impl ResponseFrame { pub fn forged_supported( request_params: FrameParams, options: &HashMap>, - ) -> Result { + ) -> Result { let mut buf = BytesMut::new(); types::write_string_multimap(options, &mut buf)?; @@ -144,7 +144,10 @@ impl ResponseFrame { } } -fn serialize_error_specific_fields(buf: &mut BytesMut, error: DbError) -> Result<(), ParseError> { +fn serialize_error_specific_fields( + buf: &mut BytesMut, + error: DbError, +) -> Result<(), std::num::TryFromIntError> { match error { DbError::Unavailable { consistency,