pub enum ConfigValue {
Inline(String),
Env(String),
}Expand description
A config value written inline or read from an environment variable.
With the serde feature it deserializes from "literal" or
{ env = "VAR_NAME" }, the same shape drizzle-kit and the CLI accept
for dbCredentials.url.
§Examples
use drizzle_types::ConfigValue;
let url = ConfigValue::Inline("postgres://localhost/app".into());
assert_eq!(url.resolve().unwrap(), "postgres://localhost/app");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>
Returns the value, reading the environment variable for ConfigValue::Env.
§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>
Returns the value, or None when a ConfigValue::Env variable 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