mitsuhiko / deser

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

Find a way to pass state to advancing de/ser methods #17

Closed mitsuhiko closed 2 years ago

mitsuhiko commented 2 years ago

Currently the SerializerState and DeserializerState is not passed to advancing methods such as next_key or next. This is done because the current stack of sinks or serializer handles is held within the state. This in turn causes challenges with lifetimes.

There are however quite a few reasons why one would want to access the state. In particular when trying to flatten serializable structures the only workaround to the lack of state is to eagerly fetch the inner struct serializers. This is possible, but causes the inner serializer to be invoked with the completely wrong state.