Skip to content

Commit

Permalink
Merge pull request scylladb#934 from muzarski/remove_strum_dependency
Browse files Browse the repository at this point in the history
Remove `strum` and `strum_macros` dependencies
  • Loading branch information
piodul authored Feb 16, 2024
2 parents 77d0089 + c463c95 commit 87908f3
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 44 deletions.
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

0 comments on commit 87908f3

Please sign in to comment.