// now: Nix-based distributed command runner
// Copyright (C) 2026 Eric Rodrigues Pires
//
// This program is free software: you can redistribute it and/or modify it under
// the terms of the GNU Affero General Public License as published by the Free
// Software Foundation, either version 3 of the License, or (at your option)
// any later version.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
// more details.
//
// You should have received a copy of the GNU Affero General Public License along
// with this program. If not, see .
use serde::Deserialize;
pub(crate) struct SecretString(String);
impl SecretString {
pub(crate) fn new(secret: String) -> Self {
Self(secret)
}
pub(crate) fn get_secret_value(&self) -> &str {
self.0.as_ref()
}
}
impl std::fmt::Debug for SecretString {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_tuple("SecretString").field(&"***").finish()
}
}
impl<'de> Deserialize<'de> for SecretString {
fn deserialize(deserializer: D) -> Result
where
D: serde::Deserializer<'de>,
{
Ok(Self(String::deserialize(deserializer)?))
}
}