Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove strum and strum_macros dependencies #934

Merged
merged 3 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 1 addition & 37 deletions Cargo.lock.msrv

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions scylla/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ openssl = { version = "0.10.32", optional = true }
tokio-openssl = { version = "0.6.1", optional = true }
arc-swap = "1.3.0"
dashmap = "5.2"
strum = "0.23"
strum_macros = "0.23"
lz4_flex = { version = "0.11.1" }
smallvec = "1.8.0"
async-trait = "0.1.56"
Expand Down
59 changes: 54 additions & 5 deletions scylla/src/transport/topology.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ use std::num::NonZeroUsize;
use std::str::FromStr;
use std::sync::Arc;
use std::time::{Duration, Instant};
use strum_macros::EnumString;
use tokio::sync::{broadcast, mpsc};
use tracing::{debug, error, trace, warn};
use uuid::Uuid;
Expand Down Expand Up @@ -255,8 +254,7 @@ pub struct MissingUserDefinedType {
pub keyspace: String,
}

#[derive(Clone, Debug, PartialEq, Eq, EnumString)]
#[strum(serialize_all = "lowercase")]
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum NativeType {
Ascii,
Boolean,
Expand All @@ -280,6 +278,40 @@ pub enum NativeType {
Varint,
}

/// [NativeType] parse error
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct NativeTypeFromStrError;

impl std::str::FromStr for NativeType {
type Err = NativeTypeFromStrError;

fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"ascii" => Ok(Self::Ascii),
"boolean" => Ok(Self::Boolean),
"blob" => Ok(Self::Blob),
"counter" => Ok(Self::Counter),
"date" => Ok(Self::Date),
"decimal" => Ok(Self::Decimal),
"double" => Ok(Self::Double),
"duration" => Ok(Self::Duration),
"float" => Ok(Self::Float),
"int" => Ok(Self::Int),
"bigint" => Ok(Self::BigInt),
"text" => Ok(Self::Text),
"timestamp" => Ok(Self::Timestamp),
"inet" => Ok(Self::Inet),
"smallint" => Ok(Self::SmallInt),
"tinyint" => Ok(Self::TinyInt),
"time" => Ok(Self::Time),
"timeuuid" => Ok(Self::Timeuuid),
"uuid" => Ok(Self::Uuid),
"varint" => Ok(Self::Varint),
_ => Err(NativeTypeFromStrError),
}
}
}

#[derive(Clone, Debug, PartialEq, Eq)]
enum PreCollectionType {
List(Box<PreCqlType>),
Expand Down Expand Up @@ -315,15 +347,32 @@ pub enum CollectionType {
Set(Box<CqlType>),
}

#[derive(Clone, Debug, PartialEq, Eq, EnumString)]
#[strum(serialize_all = "snake_case")]
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum ColumnKind {
Regular,
Static,
Clustering,
PartitionKey,
}

/// [ColumnKind] parse error
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct ColumnKindFromStrError;

impl std::str::FromStr for ColumnKind {
type Err = ColumnKindFromStrError;

fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"regular" => Ok(Self::Regular),
"static" => Ok(Self::Static),
"clustering" => Ok(Self::Clustering),
"partition_key" => Ok(Self::PartitionKey),
_ => Err(ColumnKindFromStrError),
}
}
}

#[derive(Clone, Debug, PartialEq, Eq)]
#[allow(clippy::enum_variant_names)]
pub enum Strategy {
Expand Down
Loading