mirror of
https://github.com/MercuryWorkshop/epoxy-tls.git
synced 2025-05-13 06:20:02 -04:00
add none configformat case to hide other errors
This commit is contained in:
parent
23b96c2073
commit
9d1604cc3e
1 changed files with 11 additions and 4 deletions
|
@ -339,6 +339,8 @@ impl Config {
|
|||
ConfigFormat::Json => serde_json::to_string_pretty(self)?,
|
||||
#[cfg(feature = "yaml")]
|
||||
ConfigFormat::Yaml => serde_yaml::to_string(self)?,
|
||||
#[cfg(not(any(feature = "toml", feature = "json", feature = "yaml")))]
|
||||
ConfigFormat::None => String::new(),
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -350,6 +352,8 @@ impl Config {
|
|||
ConfigFormat::Json => serde_json::from_str(&string)?,
|
||||
#[cfg(feature = "yaml")]
|
||||
ConfigFormat::Yaml => serde_yaml::from_str(&string)?,
|
||||
#[cfg(not(any(feature = "toml", feature = "json", feature = "yaml")))]
|
||||
ConfigFormat::None => { let _ = string; Self::default() },
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -362,19 +366,22 @@ pub enum ConfigFormat {
|
|||
Json,
|
||||
#[cfg(feature = "yaml")]
|
||||
Yaml,
|
||||
#[cfg(not(any(feature = "toml", feature = "json", feature = "yaml")))]
|
||||
None,
|
||||
}
|
||||
|
||||
impl Default for ConfigFormat {
|
||||
fn default() -> Self {
|
||||
cfg_if! {
|
||||
if #[cfg(feature = "toml")] {
|
||||
return Self::Toml;
|
||||
Self::Toml
|
||||
} else if #[cfg(feature = "json")] {
|
||||
return Self::Json;
|
||||
Self::Json
|
||||
} else if #[cfg(feature = "yaml")] {
|
||||
return Self::Yaml;
|
||||
Self::Yaml
|
||||
} else {
|
||||
compile_error!("no config format feature enabled - build will fail!");
|
||||
compile_error!("no config format feature enabled!");
|
||||
Self::None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue