Skip to content

Commit 87908f3

Browse files
authored
Merge pull request scylladb#934 from muzarski/remove_strum_dependency
Remove `strum` and `strum_macros` dependencies
2 parents 77d0089 + c463c95 commit 87908f3

File tree

3 files changed

+55
-44
lines changed

3 files changed

+55
-44
lines changed

Cargo.lock.msrv

+1-37
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scylla/Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ openssl = { version = "0.10.32", optional = true }
4444
tokio-openssl = { version = "0.6.1", optional = true }
4545
arc-swap = "1.3.0"
4646
dashmap = "5.2"
47-
strum = "0.23"
48-
strum_macros = "0.23"
4947
lz4_flex = { version = "0.11.1" }
5048
smallvec = "1.8.0"
5149
async-trait = "0.1.56"

scylla/src/transport/topology.rs

+54-5
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ use std::num::NonZeroUsize;
2626
use std::str::FromStr;
2727
use std::sync::Arc;
2828
use std::time::{Duration, Instant};
29-
use strum_macros::EnumString;
3029
use tokio::sync::{broadcast, mpsc};
3130
use tracing::{debug, error, trace, warn};
3231
use uuid::Uuid;
@@ -255,8 +254,7 @@ pub struct MissingUserDefinedType {
255254
pub keyspace: String,
256255
}
257256

258-
#[derive(Clone, Debug, PartialEq, Eq, EnumString)]
259-
#[strum(serialize_all = "lowercase")]
257+
#[derive(Clone, Debug, PartialEq, Eq)]
260258
pub enum NativeType {
261259
Ascii,
262260
Boolean,
@@ -280,6 +278,40 @@ pub enum NativeType {
280278
Varint,
281279
}
282280

281+
/// [NativeType] parse error
282+
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
283+
pub struct NativeTypeFromStrError;
284+
285+
impl std::str::FromStr for NativeType {
286+
type Err = NativeTypeFromStrError;
287+
288+
fn from_str(s: &str) -> Result<Self, Self::Err> {
289+
match s {
290+
"ascii" => Ok(Self::Ascii),
291+
"boolean" => Ok(Self::Boolean),
292+
"blob" => Ok(Self::Blob),
293+
"counter" => Ok(Self::Counter),
294+
"date" => Ok(Self::Date),
295+
"decimal" => Ok(Self::Decimal),
296+
"double" => Ok(Self::Double),
297+
"duration" => Ok(Self::Duration),
298+
"float" => Ok(Self::Float),
299+
"int" => Ok(Self::Int),
300+
"bigint" => Ok(Self::BigInt),
301+
"text" => Ok(Self::Text),
302+
"timestamp" => Ok(Self::Timestamp),
303+
"inet" => Ok(Self::Inet),
304+
"smallint" => Ok(Self::SmallInt),
305+
"tinyint" => Ok(Self::TinyInt),
306+
"time" => Ok(Self::Time),
307+
"timeuuid" => Ok(Self::Timeuuid),
308+
"uuid" => Ok(Self::Uuid),
309+
"varint" => Ok(Self::Varint),
310+
_ => Err(NativeTypeFromStrError),
311+
}
312+
}
313+
}
314+
283315
#[derive(Clone, Debug, PartialEq, Eq)]
284316
enum PreCollectionType {
285317
List(Box<PreCqlType>),
@@ -315,15 +347,32 @@ pub enum CollectionType {
315347
Set(Box<CqlType>),
316348
}
317349

318-
#[derive(Clone, Debug, PartialEq, Eq, EnumString)]
319-
#[strum(serialize_all = "snake_case")]
350+
#[derive(Clone, Debug, PartialEq, Eq)]
320351
pub enum ColumnKind {
321352
Regular,
322353
Static,
323354
Clustering,
324355
PartitionKey,
325356
}
326357

358+
/// [ColumnKind] parse error
359+
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
360+
pub struct ColumnKindFromStrError;
361+
362+
impl std::str::FromStr for ColumnKind {
363+
type Err = ColumnKindFromStrError;
364+
365+
fn from_str(s: &str) -> Result<Self, Self::Err> {
366+
match s {
367+
"regular" => Ok(Self::Regular),
368+
"static" => Ok(Self::Static),
369+
"clustering" => Ok(Self::Clustering),
370+
"partition_key" => Ok(Self::PartitionKey),
371+
_ => Err(ColumnKindFromStrError),
372+
}
373+
}
374+
}
375+
327376
#[derive(Clone, Debug, PartialEq, Eq)]
328377
#[allow(clippy::enum_variant_names)]
329378
pub enum Strategy {

0 commit comments

Comments
 (0)