@@ -79,14 +79,16 @@ where
79
79
T : DeserializeValue < ' frame , ' metadata > ,
80
80
{
81
81
fn type_check ( typ : & ColumnType ) -> Result < ( ) , TypeCheckError > {
82
- T :: type_check ( typ)
82
+ T :: type_check ( typ) . map_err ( typck_error_replace_rust_name :: < Self > )
83
83
}
84
84
85
85
fn deserialize (
86
86
typ : & ' metadata ColumnType < ' metadata > ,
87
87
v : Option < FrameSlice < ' frame > > ,
88
88
) -> Result < Self , DeserializationError > {
89
- v. map ( |_| T :: deserialize ( typ, v) ) . transpose ( )
89
+ v. map ( |_| T :: deserialize ( typ, v) )
90
+ . transpose ( )
91
+ . map_err ( deser_error_replace_rust_name :: < Self > )
90
92
}
91
93
}
92
94
@@ -118,6 +120,7 @@ where
118
120
#[ inline]
119
121
fn type_check ( typ : & ColumnType ) -> Result < ( ) , TypeCheckError > {
120
122
<T as DeserializeValue < ' frame , ' metadata > >:: type_check ( typ)
123
+ . map_err ( typck_error_replace_rust_name :: < Self > )
121
124
}
122
125
123
126
fn deserialize (
@@ -128,7 +131,8 @@ where
128
131
if val. is_empty ( ) {
129
132
Ok ( MaybeEmpty :: Empty )
130
133
} else {
131
- let v = <T as DeserializeValue < ' frame , ' metadata > >:: deserialize ( typ, v) ?;
134
+ let v = <T as DeserializeValue < ' frame , ' metadata > >:: deserialize ( typ, v)
135
+ . map_err ( deser_error_replace_rust_name :: < Self > ) ?;
132
136
Ok ( MaybeEmpty :: Value ( v) )
133
137
}
134
138
}
@@ -662,13 +666,16 @@ where
662
666
{
663
667
fn type_check ( typ : & ColumnType ) -> Result < ( ) , TypeCheckError > {
664
668
<T as DeserializeValue < ' frame , ' metadata > >:: type_check ( typ)
669
+ . map_err ( typck_error_replace_rust_name :: < Self > )
665
670
}
666
671
667
672
fn deserialize (
668
673
typ : & ' metadata ColumnType < ' metadata > ,
669
674
v : Option < FrameSlice < ' frame > > ,
670
675
) -> Result < Self , DeserializationError > {
671
- <T as DeserializeValue < ' frame , ' metadata > >:: deserialize ( typ, v) . map ( secrecy_08:: Secret :: new)
676
+ <T as DeserializeValue < ' frame , ' metadata > >:: deserialize ( typ, v)
677
+ . map ( secrecy_08:: Secret :: new)
678
+ . map_err ( deser_error_replace_rust_name :: < Self > )
672
679
}
673
680
}
674
681
@@ -691,6 +698,7 @@ make_error_replace_rust_name!(
691
698
// lists and sets
692
699
693
700
/// An iterator over either a CQL set or list.
701
+ #[ derive( Debug , Clone ) ]
694
702
pub struct ListlikeIterator < ' frame , ' metadata , T > {
695
703
coll_typ : & ' metadata ColumnType < ' metadata > ,
696
704
elem_typ : & ' metadata ColumnType < ' metadata > ,
@@ -873,8 +881,8 @@ where
873
881
match typ {
874
882
ColumnType :: Collection {
875
883
frozen : false ,
876
- typ : CollectionType :: Set ( el_t ) ,
877
- } => < T as DeserializeValue < ' frame , ' metadata > > :: type_check ( el_t )
884
+ typ : CollectionType :: Set ( _ ) ,
885
+ } => ListlikeIterator :: < ' frame , ' metadata , T > :: type_check ( typ )
878
886
. map_err ( typck_error_replace_rust_name :: < Self > ) ,
879
887
_ => Err ( mk_typck_err :: < Self > (
880
888
typ,
@@ -904,8 +912,8 @@ where
904
912
match typ {
905
913
ColumnType :: Collection {
906
914
frozen : false ,
907
- typ : CollectionType :: Set ( el_t ) ,
908
- } => < T as DeserializeValue < ' frame , ' metadata > > :: type_check ( el_t )
915
+ typ : CollectionType :: Set ( _ ) ,
916
+ } => ListlikeIterator :: < ' frame , ' metadata , T > :: type_check ( typ )
909
917
. map_err ( typck_error_replace_rust_name :: < Self > ) ,
910
918
_ => Err ( mk_typck_err :: < Self > (
911
919
typ,
@@ -943,6 +951,7 @@ where
943
951
/// It would be nice to have a rule to determine if the element type is fixed-length or not,
944
952
/// however, we only have a heuristic. There are a few types that should, for all intents and purposes,
945
953
/// be considered fixed-length, but are not, e.g TinyInt. See ColumnType::type_size() for the list.
954
+ #[ derive( Debug , Clone ) ]
946
955
pub struct VectorIterator < ' frame , ' metadata , T > {
947
956
collection_type : & ' metadata ColumnType < ' metadata > ,
948
957
element_type : & ' metadata ColumnType < ' metadata > ,
@@ -1101,6 +1110,7 @@ where
1101
1110
}
1102
1111
1103
1112
/// An iterator over a CQL map.
1113
+ #[ derive( Debug , Clone ) ]
1104
1114
pub struct MapIterator < ' frame , ' metadata , K , V > {
1105
1115
coll_typ : & ' metadata ColumnType < ' metadata > ,
1106
1116
k_typ : & ' metadata ColumnType < ' metadata > ,
@@ -1416,6 +1426,7 @@ impl_tuple_multiple!(
1416
1426
/// - `None` - missing from the serialized form
1417
1427
/// - `Some(None)` - present, but null
1418
1428
/// - `Some(Some(...))` - non-null, present value
1429
+ #[ derive( Debug , Clone ) ]
1419
1430
pub struct UdtIterator < ' frame , ' metadata > {
1420
1431
all_fields : & ' metadata [ ( Cow < ' metadata , str > , ColumnType < ' metadata > ) ] ,
1421
1432
type_name : & ' metadata str ,
@@ -1990,7 +2001,7 @@ impl Display for UdtTypeCheckErrorKind {
1990
2001
}
1991
2002
1992
2003
/// Deserialization of one of the built-in types failed.
1993
- #[ derive( Debug , Error ) ]
2004
+ #[ derive( Debug , Error , Clone ) ]
1994
2005
#[ error( "Failed to deserialize Rust type {rust_name} from CQL type {cql_type:?}: {kind}" ) ]
1995
2006
pub struct BuiltinDeserializationError {
1996
2007
/// Name of the Rust type being deserialized.
@@ -2025,7 +2036,7 @@ fn mk_deser_err_named(
2025
2036
}
2026
2037
2027
2038
/// Describes why deserialization of some of the built-in types failed.
2028
- #[ derive( Debug ) ]
2039
+ #[ derive( Debug , Clone ) ]
2029
2040
#[ non_exhaustive]
2030
2041
pub enum BuiltinDeserializationErrorKind {
2031
2042
/// Failed to deserialize one of date's fields.
@@ -2118,7 +2129,7 @@ impl Display for BuiltinDeserializationErrorKind {
2118
2129
}
2119
2130
2120
2131
/// Describes why deserialization of a set or list type failed.
2121
- #[ derive( Debug ) ]
2132
+ #[ derive( Debug , Clone ) ]
2122
2133
#[ non_exhaustive]
2123
2134
pub enum SetOrListDeserializationErrorKind {
2124
2135
/// Failed to deserialize set or list's length.
@@ -2149,7 +2160,7 @@ impl From<SetOrListDeserializationErrorKind> for BuiltinDeserializationErrorKind
2149
2160
}
2150
2161
2151
2162
/// Describes why deserialization of a vector type failed.
2152
- #[ derive( Error , Debug ) ]
2163
+ #[ derive( Error , Debug , Clone ) ]
2153
2164
#[ non_exhaustive]
2154
2165
pub enum VectorDeserializationErrorKind {
2155
2166
/// One of the elements of the vector failed to deserialize.
@@ -2165,7 +2176,7 @@ impl From<VectorDeserializationErrorKind> for BuiltinDeserializationErrorKind {
2165
2176
}
2166
2177
2167
2178
/// Describes why deserialization of a map type failed.
2168
- #[ derive( Debug ) ]
2179
+ #[ derive( Debug , Clone ) ]
2169
2180
#[ non_exhaustive]
2170
2181
// Check triggers because all variants end with "DeserializationFailed".
2171
2182
// TODO(2.0): Remove the "DeserializationFailed" postfix from variants.
0 commit comments