pub enum ConfigValue {
Inline(String),
Env(String),
}Expand description
A config value that is either inline or an env-var reference.
In TOML this deserializes from "literal" or { env = "VAR_NAME" } — the
same shape drizzle-kit and the CLI accept for dbCredentials.url. Used
anywhere a config value can be either inline or pulled from the
environment at runtime.
Variants§
Inline(String)
Value written inline in the config file.
Env(String)
Name of the environment variable to resolve.
Implementations§
Source§impl ConfigValue
impl ConfigValue
Sourcepub fn resolve(&self) -> Result<String, ConfigValueError>
pub fn resolve(&self) -> Result<String, ConfigValueError>
Resolve to a concrete string, reading the environment if needed.
§Errors
Returns ConfigValueError::NotPresent if this is a ConfigValue::Env pointing
to a variable that is not set, or ConfigValueError::NotUnicode if the
variable is set but contains invalid UTF-8.
Sourcepub fn resolve_optional(&self) -> Result<Option<String>, ConfigValueError>
pub fn resolve_optional(&self) -> Result<Option<String>, ConfigValueError>
Resolve to an optional value (returns None when an Env var is unset).
§Errors
Returns ConfigValueError::NotUnicode if the env var is set but contains
invalid UTF-8. Missing env vars resolve to Ok(None).
Trait Implementations§
Source§impl Clone for ConfigValue
impl Clone for ConfigValue
Source§fn clone(&self) -> ConfigValue
fn clone(&self) -> ConfigValue
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ConfigValue
impl Debug for ConfigValue
Source§impl<'de> Deserialize<'de> for ConfigValue
Available on crate feature serde only.
impl<'de> Deserialize<'de> for ConfigValue
serde only.Source§fn deserialize<D>(
deserializer: D,
) -> Result<ConfigValue, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<ConfigValue, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
impl Eq for ConfigValue
Source§impl JsonSchema for ConfigValue
Available on crate feature schemars only.
impl JsonSchema for ConfigValue
schemars only.Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read more