bincode-org / bincode

A binary encoder / decoder implementation in Rust.
MIT License
2.63k stars 265 forks source link

Add codec support for chrone #689

Closed RuofengX closed 6 months ago

RuofengX commented 8 months ago

I am writing a typed wrapper for sled database using bincode-2.0.0-rc3 based on the typed-sled which use bincode-1 to do the codec thing.

When I writing the example part of bincode-sled, I found that a struct which contains chrono::DateTime<chrono::Utc> cannot auto-derive the Encode and Decode trait, I could only turn to using a SystemTime as a work around.

source code is here

RuofengX commented 8 months ago

Typed-sled use derive marco of serde, which could derive the chrone::Datetime successfully.

VictorKoenders commented 8 months ago

For interop with bincode’s derive feature, you can use the #[bincode(with_serde)] attribute on each field that implements serde’s traits.

https://docs.rs/bincode/2.0.0-rc.3/bincode/serde/index.html

Would this work?

stale[bot] commented 6 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.