INNER CODE UNIT · Rust
fmt
szabodanika/microbin · src/args.rs:258
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.0)
}
}
#[derive(Debug, Clone, Serialize)]
pub struct SecretArg(pub String);
impl FromStr for SecretArg {
type Err = String;
fn from_str(s: &str) -> Result<Self, Self::Err> {
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 {