quininer / cbor4ii

CBOR: Concise Binary Object Representation
MIT License
54 stars 5 forks source link

serde: give access to underlying writer #15

Closed vmx closed 2 years ago

vmx commented 2 years ago

When using the Serializer from an external crate it can be useful to be able to access the underlying writer.

It turns out that the code I posted at https://github.com/quininer/cbor4ii/issues/13#issuecomment-1095342912 only works with this patch.

vmx commented 2 years ago

In turns out that I probably don't need this change. I tried to wrap your Serializer in my own custom serializer and changed just a few serialize_*() functions. I had hoped I could re-use the serialize implementations for sequences, maps, tuples and structs. But as they call into their serializer (via self.ser), they won't call into my own serializer. This means that I would need to implement those myself and also need code to call them. There won't be much left to wrap, so I think it's easier to just copy and paste the current serializer, adapt it to my needs and disable the serde1 feature, so that I only rely on core.

If you still want this change, I'll rename the function to get_mut(), if not, feel free to close this PR.

PS: Thanks for always responding that fast!

quininer commented 2 years ago

If no one needs it, I tend to keep it private. Thank you.