SoftbearStudios / bitcode

A binary encoder/decoder for Rust
https://crates.io/crates/bitcode/
MIT License
369 stars 19 forks source link

Implement Encode/Decode for `std::time::Duration` #25

Closed LGFae closed 7 months ago

LGFae commented 7 months ago

Hello, thanks a lot for this library.

Would it be possible to implement Encode/Decode for std::time::Duration?. My use case is for a wallpaper daemon (swww) that play animations like gifs. I need to serialize the frame's duration, since for some image formats (like gif), they may not be the same for all frames in the image.

Right now, I am probably just going to go with a u128 representing nanoseconds, but it would be nice if I could just continue to use Duration directly, like I did when using rkyv.

caibear commented 7 months ago

https://github.com/SoftbearStudios/bitcode/commit/5f25a59be3e66deef721e7eb2369deb1aa32d263