use crate::{
error::{Error, ErrorKind},
secrets::{SecretBytes, SecretMap, encodings::strip_ascii_whitespace},
};
#[derive(Debug, Clone, Copy, Default)]
pub struct HexEncoding;
impl SecretMap for HexEncoding {
type In = SecretBytes;
type Out = SecretBytes;
fn apply(&self, input: SecretBytes) -> Result<SecretBytes, Error> {
let stripped = strip_ascii_whitespace(input.expose_secret(), |b| b);
let decoded =
hex::decode(&*stripped).map_err(|source| Error::new(ErrorKind::Config, source))?;
Ok(SecretBytes::new(decoded))
}
}