mitsuhiko / deser

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

Consider moving finish() on Serialize #19

Closed mitsuhiko closed 2 years ago

mitsuhiko commented 2 years ago

It seems a bit odd that the main purpose of finish on Serialize is to undo state changes for the nested emitters, but it can't be conditional on the state of the emitters. If the method were to move onto the emitters then the state of the emitter can be used to undo the state in the serializer.

Relatedly recent changes now call finish for atoms as well on the deserializing sink. This seems wasteful.

mitsuhiko commented 2 years ago

I tried a few things now and while it's odd that you can't access the the emitters that's not much of an issue as the main use of finish is to wrap the whole thing anyways. I will close this now as moving this to the emitters actually makes the main use of it a lot less ergonomical.