Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FR: Add new field attribute "skip_serializing_when" #2762

Open
hxzhao527 opened this issue Jun 24, 2024 · 0 comments
Open

FR: Add new field attribute "skip_serializing_when" #2762

hxzhao527 opened this issue Jun 24, 2024 · 0 comments

Comments

@hxzhao527
Copy link

hxzhao527 commented Jun 24, 2024

similar as #818.
but this allows different values for the same type.
for example

#[derive(Debug, serde::Deserialize, serde::Serialize)]
struct TCP {
    #[serde(skip_serializing_when = true)]
    no_delay: bool,
    #[serde(skip_serializing_when = true)]
    keep_alive: bool,
    #[serde(skip_serializing_when = false)]
    prefer_ipv4: bool,
}
#[derive(Debug, serde::Deserialize, serde::Serialize)]
struct Mux {
    enabled: bool,
    #[serde(skip_serializing_when = 8)]
    concurrency: u32,
    #[serde(skip_serializing_if = 60)]
    idle_timeout: u64,
}

#[derive(Debug, serde::Deserialize, serde::Serialize)]
struct Router {
    enabled: bool,
    bypass: Vec<String>,
    proxy: Vec<String>,
    block: Vec<String>,
    #[serde(skip_serializing_when = "proxy".to_string())]
    default_policy: String,
    #[serde(skip_serializing_when = "as_is".to_string())]
    domain_strategy: String,
    geoip: String,
    geosite: String,
}
@hxzhao527 hxzhao527 changed the title Add new field attribute "skip_serializing_when" FR: Add new field attribute "skip_serializing_when" Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant