cuprated/config/
default.rs

1use serde::{Deserialize, Serialize};
2
3/// An enum that can be either a default value or a custom value.
4///
5/// Useful when config value's defaults depend on other values, i.e. the default ports to listen on
6/// depend on the network chosen.
7///
8/// The [`DefaultOrCustom::Default`] variant will be serialised as a string: "Default",
9/// [`DefaultOrCustom::Custom`] will just use the serialisation of the inner value.
10#[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
11pub enum DefaultOrCustom<T> {
12    Default,
13    #[serde(untagged)]
14    Custom(T),
15}