mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-01 11:06:50 +08:00
refactor(masking): PII improvements (#77)
This commit is contained in:
@ -3,14 +3,14 @@ use core::fmt;
|
||||
/// Debugging trait which is specialized for handling secret values
|
||||
pub trait Strategy<T> {
|
||||
/// Format information about the secret's type.
|
||||
fn fmt(value: &T, fmt: &mut fmt::Formatter<'_>) -> std::fmt::Result;
|
||||
fn fmt(value: &T, fmt: &mut fmt::Formatter<'_>) -> fmt::Result;
|
||||
}
|
||||
|
||||
/// Debug with type
|
||||
pub struct WithType;
|
||||
|
||||
impl<T> Strategy<T> for WithType {
|
||||
fn fmt(_: &T, fmt: &mut fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
fn fmt(_: &T, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
fmt.write_str("*** ")?;
|
||||
fmt.write_str(std::any::type_name::<T>())?;
|
||||
fmt.write_str(" ***")
|
||||
@ -21,18 +21,7 @@ impl<T> Strategy<T> for WithType {
|
||||
pub struct WithoutType;
|
||||
|
||||
impl<T> Strategy<T> for WithoutType {
|
||||
fn fmt(_: &T, fmt: &mut fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
fn fmt(_: &T, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
fmt.write_str("*** ***")
|
||||
}
|
||||
}
|
||||
|
||||
pub struct NoMasking;
|
||||
|
||||
impl<T> Strategy<T> for NoMasking
|
||||
where
|
||||
T: fmt::Display,
|
||||
{
|
||||
fn fmt(val: &T, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
fmt::Display::fmt(val, f)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user