3Hren / msgpack-rust

MessagePack implementation for Rust / msgpack.org[Rust]
MIT License
1.1k stars 124 forks source link

rmp_serde: serialize and deserialize MessagePack extensions #182

Open 1tgr opened 5 years ago

1tgr commented 5 years ago

The toml crate has a trick for this. Their serialize_struct recognises their built-in datetime type by name, and delegates to a specialised serializer: https://github.com/alexcrichton/toml-rs/blob/c1a369f44762045e65989caa9491e153d1f358e6/src/ser.rs#L949-L952

Likewise to deserialize: https://github.com/alexcrichton/toml-rs/blob/c1a369f44762045e65989caa9491e153d1f358e6/src/de.rs#L582-L589

vmx commented 4 years ago

I think this was fixed by https://github.com/3Hren/msgpack-rust/commit/a34ab8fcca9f1133ec1c4fc446a59b71acf5613e.

yan-zaretskiy commented 4 years ago

Is it possible to provide a small code example of how to use extension types to serialize individual fields in a struct?