INNER CODE UNIT · Rust
Some
szabodanika/microbin · src/args.rs:270
if let Some(path) = s.strip_prefix("file://").or_else(|| s.strip_prefix("file:")) {
// Read value from file
fs::read_to_string(path)
.map(|content| SecretArg(content.trim().to_string()))
.map_err(|e| format!("Failed to read secret from {}: {}", path, e))
} else {
// Use the raw string provided
Ok(SecretArg(s.to_string()))
}
}
}
// Allow it to be treated like a string automatically
impl std::ops::Deref for SecretArg {
type Target = String;
fn deref(&self) -> &Self::Target {
&self.0
}