@@ -63,13 +63,18 @@ pub trait IsScalar<SchemaType> {
6363 /// The schema marker type this scalar represents.
6464 type SchemaType ;
6565
66+ // TODO: serialize should maybe be on an OutputScalar trait
6667 fn serialize < S > ( & self , serializer : S ) -> Result < S :: Ok , S :: Error >
6768 where
6869 S : Serializer ;
6970}
7071
71- // TODO: better name on this
72- pub trait ScalarDeser < SchemaType > : IsScalar < SchemaType > + Sized {
72+ // TODO: serialize should maybe be on an InputScalar trait
73+ // or maybe just ScalarSerialize/ScalarDeserialize? not sure...
74+ pub trait IsOutputScalar < SchemaType > : Sized {
75+ /// The schema marker type this scalar represents.
76+ type SchemaType ;
77+
7378 fn deserialize < ' de , D > ( deserializer : D ) -> Result < Self , D :: Error >
7479 where
7580 D : Deserializer < ' de > ;
@@ -103,10 +108,12 @@ where
103108 }
104109}
105110
106- impl < T , U > ScalarDeser < Option < T > > for Option < U >
111+ impl < T , U > IsOutputScalar < Option < T > > for Option < U >
107112where
108- U : ScalarDeser < T > ,
113+ U : IsOutputScalar < T > ,
109114{
115+ type SchemaType = Option < U :: SchemaType > ;
116+
110117 fn deserialize < ' de , D > ( deserializer : D ) -> Result < Self , D :: Error >
111118 where
112119 D : Deserializer < ' de > ,
@@ -129,10 +136,12 @@ where
129136 }
130137}
131138
132- impl < T , U > ScalarDeser < Vec < T > > for Vec < U >
139+ impl < T , U > IsOutputScalar < Vec < T > > for Vec < U >
133140where
134- U : ScalarDeser < T > ,
141+ U : IsOutputScalar < T > ,
135142{
143+ type SchemaType = Vec < U :: SchemaType > ;
144+
136145 fn deserialize < ' de , D > ( deserializer : D ) -> Result < Self , D :: Error >
137146 where
138147 D : Deserializer < ' de > ,
@@ -183,10 +192,12 @@ where
183192 }
184193}
185194
186- impl < T , U : ?Sized > ScalarDeser < Box < T > > for Box < U >
195+ impl < T , U : ?Sized > IsOutputScalar < Box < T > > for Box < U >
187196where
188- U : ScalarDeser < T > ,
197+ U : IsOutputScalar < T > ,
189198{
199+ type SchemaType = Box < U :: SchemaType > ;
200+
190201 fn deserialize < ' de , D > ( deserializer : D ) -> Result < Self , D :: Error >
191202 where
192203 D : Deserializer < ' de > ,
@@ -209,10 +220,12 @@ where
209220 }
210221}
211222
212- impl < T , U : ?Sized > ScalarDeser < T > for std:: borrow:: Cow < ' _ , U >
223+ impl < T , U : ?Sized > IsOutputScalar < T > for std:: borrow:: Cow < ' _ , U >
213224where
214- U : ScalarDeser < T > + ToOwned ,
225+ U : IsOutputScalar < T > + ToOwned ,
215226{
227+ type SchemaType = U :: SchemaType ;
228+
216229 fn deserialize < ' de , D > ( deserializer : D ) -> Result < Self , D :: Error >
217230 where
218231 D : Deserializer < ' de > ,
@@ -232,7 +245,9 @@ impl IsScalar<bool> for bool {
232245 }
233246}
234247
235- impl ScalarDeser < bool > for bool {
248+ impl IsOutputScalar < bool > for bool {
249+ type SchemaType = bool ;
250+
236251 fn deserialize < ' de , D > ( deserializer : D ) -> Result < Self , D :: Error >
237252 where
238253 D : Deserializer < ' de > ,
@@ -252,7 +267,9 @@ impl IsScalar<String> for String {
252267 }
253268}
254269
255- impl ScalarDeser < String > for String {
270+ impl IsOutputScalar < String > for String {
271+ type SchemaType = String ;
272+
256273 fn deserialize < ' de , D > ( deserializer : D ) -> Result < Self , D :: Error >
257274 where
258275 D : Deserializer < ' de > ,
@@ -283,7 +300,9 @@ impl IsScalar<i32> for i32 {
283300 }
284301}
285302
286- impl ScalarDeser < i32 > for i32 {
303+ impl IsOutputScalar < i32 > for i32 {
304+ type SchemaType = i32 ;
305+
287306 fn deserialize < ' de , D > ( deserializer : D ) -> Result < Self , D :: Error >
288307 where
289308 D : Deserializer < ' de > ,
@@ -303,7 +322,9 @@ impl IsScalar<f64> for f64 {
303322 }
304323}
305324
306- impl ScalarDeser < f64 > for f64 {
325+ impl IsOutputScalar < f64 > for f64 {
326+ type SchemaType = f64 ;
327+
307328 fn deserialize < ' de , D > ( deserializer : D ) -> Result < Self , D :: Error >
308329 where
309330 D : Deserializer < ' de > ,
@@ -323,7 +344,9 @@ impl IsScalar<crate::Id> for crate::Id {
323344 }
324345}
325346
326- impl ScalarDeser < crate :: Id > for crate :: Id {
347+ impl IsOutputScalar < crate :: Id > for crate :: Id {
348+ type SchemaType = crate :: Id ;
349+
327350 fn deserialize < ' de , D > ( deserializer : D ) -> Result < Self , D :: Error >
328351 where
329352 D : Deserializer < ' de > ,
0 commit comments