mitsuhiko / deser

Experimental rust serialization library
https://docs.rs/deser
Apache License 2.0
287 stars 8 forks source link

Better Type Descriptors #8

Open mitsuhiko opened 2 years ago

mitsuhiko commented 2 years ago

Right now the type descriptors are not very useful for anything that is a compound type. For instance the type descriptor for Option<T> cannot properly express what's going on. The same applies to Vec<T> which cannot really talk about what the T is.

More importantly the design does not provide for more interesting answers that one needs to have about types such as if a value might need to be skipped on serialization or deserialization (#3).

mitsuhiko commented 2 years ago

Another issue with the descriptors right now is that you can only return borrow the hole thing. Which means that when implementing newtypes the implementation of the descriptor can only pick between returning a new one (with for instance a custom name) or the internal one and forward it completely transparently.

So for instance a NewType(u32) needs to pick between reporting NewType as name or the internal name with 4 as precision.