You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What version of Rust are you using? rustc 1.71.1 (eb26296b5 2023-08-03)
What operating system are you using? NixOS 23.05 (Linux)
What versions of the driver and its dependencies are you using? mongodb@2.6.0 & bson@2.6.1
Describe the bug
serde_with's DeserializeAs & SerializeAs are currently only implemented for chrono. It would be nice to see them supported for time's OffsetDateTime & PrimitiveDateTime as well.
To Reproduce
use serde::{Deserialize,Serialize};use serde_with::serde_as;#[derive(Clone,Debug,Serialize,Deserialize)]pubstructBanana{#[serde_as(as = "Option<bson::DateTime>")]pubexpires:Option<time::OffsetDateTime>,}
Additional Notes
Because proper support for serde_with is missing, I'm currently using:
But this doesn't work when my OffsetDateTime is wrapped in an Option like in the example above.
Is there another way to achieve this right now before full with_serde support is implemented?
The text was updated successfully, but these errors were encountered:
Oh, I just saw that support has recently been implemented on main for time::OffsetDateTime: 09a8cbb
Guess we'll just have to wait for a new release then.
Not sure if it makes sense to implement it for PrimitiveDateTime as well (I haven't used it yet myself), but if it does that would also be nice to have.
Hi @felschr, we will likely be doing a bson release this week, so this functionality will be available then. Feel free to file a ticket in our Jira project if you would be interested in PrimitiveDateTime support!
Versions/Environment
mongodb@2.6.0
&bson@2.6.1
Describe the bug
serde_with's
DeserializeAs
&SerializeAs
are currently only implemented for chrono. It would be nice to see them supported for time'sOffsetDateTime
&PrimitiveDateTime
as well.To Reproduce
Additional Notes
Because proper support for
serde_with
is missing, I'm currently using:#[serde(with = "bson::serde_helpers::time_0_3_offsetdatetime_as_bson_datetime")]
But this doesn't work when my
OffsetDateTime
is wrapped in anOption
like in the example above.Is there another way to achieve this right now before full
with_serde
support is implemented?The text was updated successfully, but these errors were encountered: