Skip to main content

var_optional

Function var_optional 

Source
pub fn var_optional(name: &str) -> Result<Option<String>, SealedEnvError>
Expand description

Read a variable, returning Ok(None) if it is not set.

If the variable exists and is encrypted, it will be decrypted. If it is not encrypted, the plaintext is returned.

ยงExamples

use sealed_env::var_optional;

std::env::set_var("SEALED_KEY", "<base64-key>");

let value = var_optional("OPTIONAL_SECRET")?;