ploidy_codegen_rust/
config.rs

1use serde::{Deserialize, Serialize};
2
3/// Configuration for Rust code generation, read from `[package.metadata.ploidy]`
4/// in the `Cargo.toml` of the generated crate.
5#[derive(Clone, Debug, Default, Deserialize, Serialize)]
6#[serde(rename_all = "kebab-case")]
7pub struct CodegenConfig {
8    #[serde(default)]
9    pub date_time_format: DateTimeFormat,
10}
11
12/// The format to use for `date-time` types.
13#[derive(Clone, Copy, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
14#[serde(rename_all = "kebab-case")]
15pub enum DateTimeFormat {
16    /// RFC 3339 (ISO 8601) format, using `chrono::DateTime<Utc>`.
17    /// This is how OpenAPI 3.0 represents `date-time` types.
18    #[default]
19    Rfc3339,
20
21    /// Unix timestamps in seconds, using `ploidy_util::UnixSeconds`.
22    /// This is also the representation for the `unix-time` type.
23    UnixSeconds,
24
25    /// Unix timestamps in milliseconds, using `ploidy_util::UnixMilliseconds`.
26    UnixMilliseconds,
27
28    /// Unix timestamps in microseconds, using `ploidy_util::UnixMicroseconds`.
29    UnixMicroseconds,
30
31    /// Unix timestamps in nanoseconds, using `ploidy_util::UnixNanoseconds`.
32    UnixNanoseconds,
33}