pub fn expose_secret_string<S: Serializer>(
secret: &SecretString,
ser: S,
) -> Result<S::Ok, S::Error>Expand description
Enables serialization of secrecy::SecretString fields by exposing the inner string.
ยงExamples
#[derive(Debug, Serialize)]
struct Login {
#[serde(serialize_with = "serde_secrecy::expose_secret_string")]
password: SecretString,
}
let req = Login {
password: SecretString::from("hunter2"),
};
let json = serde_json::to_string(&req).unwrap();
assert!(json.contains("hunter2"));