#[cfg(feature = "decrypt")]
#[macro_export]
#[doc(hidden)]
macro_rules! __save_encrypted_method {
($key:expr) => {
pub fn save_encrypted(
&self,
path: impl ::core::convert::AsRef<::std::path::Path>,
encryptor: &dyn $crate::Encryptor,
) -> ::core::result::Result<(), $crate::Error> {
let path = path.as_ref();
let format = $crate::Format::from_path(path)?;
$crate::save_encrypted(self, path, format, $key, encryptor)
}
};
}
#[cfg(not(feature = "decrypt"))]
#[macro_export]
#[doc(hidden)]
macro_rules! __save_encrypted_method {
($key:expr) => {};
}
#[cfg(feature = "dotenv")]
#[macro_export]
#[doc(hidden)]
macro_rules! __require_dotenv {
() => {};
}
#[cfg(not(feature = "dotenv"))]
#[macro_export]
#[doc(hidden)]
macro_rules! __require_dotenv {
() => {
::core::compile_error!(
"dynamic-config: `env_files` in #[dynamic_config(..)] requires the `dotenv` \
feature; add features = [\"dotenv\"] to your dynamic-config dependency"
);
};
}
#[cfg(feature = "decrypt")]
#[macro_export]
#[doc(hidden)]
macro_rules! __source_encrypted {
($path:expr, $format:expr) => {
$crate::Source::encrypted($path, $format)
};
}
#[cfg(not(feature = "decrypt"))]
#[macro_export]
#[doc(hidden)]
macro_rules! __source_encrypted {
($path:expr, $format:expr) => {{
::core::compile_error!(
"dynamic-config: a `.age` config file needs decryption support; \
add features = [\"age\"] to your dynamic-config dependency"
);
$crate::Source::file($path, $format)
}};
}
#[cfg(feature = "json")]
#[macro_export]
#[doc(hidden)]
macro_rules! __format_json {
() => {
$crate::Format::Json
};
}
#[cfg(not(feature = "json"))]
#[macro_export]
#[doc(hidden)]
macro_rules! __format_json {
() => {
::core::compile_error!(
"dynamic-config: `.json` files require the `json` feature; \
add features = [\"json\"] to your dynamic-config dependency"
)
};
}
#[cfg(feature = "toml")]
#[macro_export]
#[doc(hidden)]
macro_rules! __format_toml {
() => {
$crate::Format::Toml
};
}
#[cfg(not(feature = "toml"))]
#[macro_export]
#[doc(hidden)]
macro_rules! __format_toml {
() => {
::core::compile_error!(
"dynamic-config: `.toml` files require the `toml` feature; \
add features = [\"toml\"] to your dynamic-config dependency"
)
};
}
#[cfg(feature = "yaml")]
#[macro_export]
#[doc(hidden)]
macro_rules! __format_yaml {
() => {
$crate::Format::Yaml
};
}
#[cfg(not(feature = "yaml"))]
#[macro_export]
#[doc(hidden)]
macro_rules! __format_yaml {
() => {
::core::compile_error!(
"dynamic-config: `.yaml` and `.yml` files require the `yaml` feature; \
add features = [\"yaml\"] to your dynamic-config dependency"
)
};
}
#[cfg(feature = "watch")]
#[macro_export]
#[doc(hidden)]
macro_rules! __spawn_watch {
($($argument:tt)*) => {
$crate::watch::spawn_with($($argument)*)
};
}
#[cfg(not(feature = "watch"))]
#[macro_export]
#[doc(hidden)]
macro_rules! __spawn_watch {
($($argument:tt)*) => {
::core::compile_error!(
"dynamic-config: `watch` in #[dynamic_config(..)] requires the `watch` feature; \
add features = [\"watch\"] to your dynamic-config dependency"
)
};
}
#[cfg(feature = "clap")]
#[macro_export]
#[doc(hidden)]
macro_rules! __clap_methods {
() => {
pub fn bind_clap(
matches: &$crate::__private::clap::ArgMatches,
bindings: &[(&str, &str)],
) -> ::core::result::Result<(), $crate::Error> {
Self::dynamic_config_flags().bind_clap(matches, bindings)
}
};
}
#[cfg(not(feature = "clap"))]
#[macro_export]
#[doc(hidden)]
macro_rules! __clap_methods {
() => {};
}
#[cfg(feature = "schema")]
#[macro_export]
#[doc(hidden)]
macro_rules! __schema_methods {
($key:expr, $secrets:expr) => {
pub fn schema() -> ::dynamic_config::__private::serde_json::Value
where
Self: ::dynamic_config::__private::schemars::JsonSchema,
{
let generated = ::dynamic_config::__private::schemars::schema_for!(Self);
::dynamic_config::schema::section(
$key,
::core::convert::Into::into(generated),
$secrets,
)
}
};
}
#[cfg(not(feature = "schema"))]
#[macro_export]
#[doc(hidden)]
macro_rules! __schema_methods {
($key:expr, $secrets:expr) => {
::core::compile_error!(
"dynamic-config: `schema` in #[dynamic_config(..)] requires the `schema` feature; \
add features = [\"schema\"] to your dynamic-config dependency"
);
};
}
#[cfg(feature = "async")]
#[macro_export]
#[doc(hidden)]
macro_rules! __async_methods {
($name:ident) => {
pub async fn load_async() -> ::core::result::Result<Self, $crate::Error> {
$crate::load_async(Self::dynamic_config_spec()).await
}
pub async fn init_async() -> ::core::result::Result<(), $crate::Error> {
$crate::off_thread(Self::dynamic_config_apply).await?;
::core::result::Result::Ok(())
}
pub fn changes() -> $crate::Changes<Self> {
Self::dynamic_config_cell().changes()
}
};
}
#[cfg(feature = "async")]
#[macro_export]
#[doc(hidden)]
macro_rules! __async_remote_methods {
() => {
pub fn set_remote_async(source: impl $crate::AsyncRemoteSource) {
Self::dynamic_config_remote().set_async(source);
}
pub async fn refresh_remote_async() -> ::core::result::Result<(), $crate::Error> {
Self::dynamic_config_remote().refresh_async().await
}
};
}
#[cfg(not(feature = "async"))]
#[macro_export]
#[doc(hidden)]
macro_rules! __async_remote_methods {
() => {};
}
#[cfg(not(feature = "async"))]
#[macro_export]
#[doc(hidden)]
macro_rules! __async_methods {
($name:ident) => {
::core::compile_error!(
"dynamic-config: `async` in #[dynamic_config(..)] requires the `async` feature \
(or `tokio`, which implies it); add features = [\"async\"] to your \
dynamic-config dependency"
);
};
}