@@ -26,7 +26,6 @@ use std::num::NonZeroUsize;
26
26
use std:: str:: FromStr ;
27
27
use std:: sync:: Arc ;
28
28
use std:: time:: { Duration , Instant } ;
29
- use strum_macros:: EnumString ;
30
29
use tokio:: sync:: { broadcast, mpsc} ;
31
30
use tracing:: { debug, error, trace, warn} ;
32
31
use uuid:: Uuid ;
@@ -255,8 +254,7 @@ pub struct MissingUserDefinedType {
255
254
pub keyspace : String ,
256
255
}
257
256
258
- #[ derive( Clone , Debug , PartialEq , Eq , EnumString ) ]
259
- #[ strum( serialize_all = "lowercase" ) ]
257
+ #[ derive( Clone , Debug , PartialEq , Eq ) ]
260
258
pub enum NativeType {
261
259
Ascii ,
262
260
Boolean ,
@@ -280,6 +278,40 @@ pub enum NativeType {
280
278
Varint ,
281
279
}
282
280
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
+
283
315
#[ derive( Clone , Debug , PartialEq , Eq ) ]
284
316
enum PreCollectionType {
285
317
List ( Box < PreCqlType > ) ,
@@ -315,15 +347,32 @@ pub enum CollectionType {
315
347
Set ( Box < CqlType > ) ,
316
348
}
317
349
318
- #[ derive( Clone , Debug , PartialEq , Eq , EnumString ) ]
319
- #[ strum( serialize_all = "snake_case" ) ]
350
+ #[ derive( Clone , Debug , PartialEq , Eq ) ]
320
351
pub enum ColumnKind {
321
352
Regular ,
322
353
Static ,
323
354
Clustering ,
324
355
PartitionKey ,
325
356
}
326
357
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
+
327
376
#[ derive( Clone , Debug , PartialEq , Eq ) ]
328
377
#[ allow( clippy:: enum_variant_names) ]
329
378
pub enum Strategy {
0 commit comments