-
I am trying to do what this documentation says to set the iso8601 to four digits instead of six. My code is quite simple. The only peculiarity is that I use serde re-exported from rocket to avoid versioning problems. use rocket::serde::{Deserialize, Serialize};
use time::OffsetDateTime;
use time::format_description::well_known::{iso8601, Iso8601};
const CONFIG: iso8601::EncodedConfig = iso8601::Config::DEFAULT
.set_year_is_six_digits(false)
.encode();
const FORMAT: Iso8601<CONFIG> = Iso8601::<CONFIG>;
time::serde::format_description!(my_format, OffsetDateTime, FORMAT);
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(crate = "rocket::serde")]
pub struct LesmaMeta {
pub hash: String,
pub password: Option<String>,
pub name: String,
pub binary: bool,
pub limit: u8,
pub current: u8,
#[serde(with = "my_format")]
pub create: OffsetDateTime,
#[serde(with = "my_format")]
pub expire: OffsetDateTime
} If I run this I get the following error:
Possibly the problem is because I'm using the re-exported serde, but I can't figure out how to fix it (or if there is a solution). Any ideas? |
Beta Was this translation helpful? Give feedback.
Answered by
jhpratt
May 29, 2023
Replies: 1 comment 2 replies
-
|
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm not certain why you need a lower version of serde, but you have to have it as a direct dependency. There is no way around this at the moment. It's a technical restriction.