pub enum EnvOr {
Value(String),
Env(String),
}Expand description
A value that’s either a literal string 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§
Value(String)
Literal value taken from the config file.
Env(String)
Name of the environment variable to resolve.
Implementations§
Source§impl EnvOr
impl EnvOr
Sourcepub fn resolve(&self) -> Result<String, EnvOrError>
pub fn resolve(&self) -> Result<String, EnvOrError>
Resolve to a concrete string, reading the environment if needed.
§Errors
Returns EnvOrError::NotPresent if this is an EnvOr::Env pointing
to a variable that is not set, or EnvOrError::NotUnicode if the
variable is set but contains invalid UTF-8.
Sourcepub fn resolve_optional(&self) -> Result<Option<String>, EnvOrError>
pub fn resolve_optional(&self) -> Result<Option<String>, EnvOrError>
Resolve to an optional value (returns None when an Env var is unset).
§Errors
Returns EnvOrError::NotUnicode if the env var is set but contains
invalid UTF-8. Missing env vars resolve to Ok(None).