serde: Unable to serialize sequence without knowing all elements.
In the logging library I’m working on, I would like to serialize map elements, provided by user API calls. However at any given time, I have only one key: value
pair.
So I can’t efficiently serialize a map:
fn serialize_map<V>(&mut self, visitor: V) -> Result<(), Self::Error> where V: MapVisitor;
fn serialize_map_elt<K, V>(&mut self, key: K, value: V) -> Result<(), Self::Error> where K: Serialize, V: Serialize;
As I have to build a Visitor
If the API would be returning some kind of Visitor
that one can call to serialize field after field, then both my and currently-supported use cases would work. Would it be worse in some aspect that I’m missing?
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 16 (16 by maintainers)
I got something working… Fixing tests now
Awesome. I’ll try to integrate json with your design tomorrow to see how it holds up against a real format impl