msgpack-rust
msgpack-rust copied to clipboard
Adding Timestamp decode/encode
This is a baseline just to have something to work off of, very WIP.
- ~~Should we perhaps just use DateTime from the chrono crate under a feature flag instead of creating a simple enum.~~ (I've decided against this, it's too much of a hassle.)
- ~~How should we go about including it in rmp-serde if at all?~~ (Made an initial implementation, but kind of hacky, awaiting feedback)
- Checking for invalid values (ie. nanos above 999_999_999) should probably be done better. I am not too familiar with this library and how I should be propagating such errors. (Especially with serde.)
- Also, please advise on any formatting requests. (I turned off rustfmt)
Let me know if this isn't something you're interested it.
@junderw thank you for getting this started 🙏 I'm interested in using this with serde, but I don't understand either library well enough to know what code to add to rmp_serde so that I can use rmp::Timestamp in my structs. Would you be interested in collaborating on this?
@jcuffe I added a hackey TimestampSerde wrapper. It's a simple wrapper only for serde serialize and deserialize.
The content is pub, so you can just take the content out after it's deserialized.
I added a test for each way, you can look at the test to see how it works.
Excellent! Thank you @junderw 😁