@@ -26,7 +26,6 @@ use std::num::NonZeroUsize;
2626use std:: str:: FromStr ;
2727use std:: sync:: Arc ;
2828use std:: time:: { Duration , Instant } ;
29- use strum_macros:: EnumString ;
3029use tokio:: sync:: { broadcast, mpsc} ;
3130use tracing:: { debug, error, trace, warn} ;
3231use 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 ) ]
260258pub 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 ) ]
284316enum 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 ) ]
320351pub 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) ]
329378pub enum Strategy {
0 commit comments