mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-30 17:47:54 +08:00
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
30 lines
788 B
Rust
30 lines
788 B
Rust
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<'_>) -> fmt::Result;
|
|
}
|
|
|
|
/// Debug with type
|
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
|
|
#[derive(Debug, Copy, Clone, PartialEq)]
|
|
pub enum WithType {}
|
|
|
|
impl<T> Strategy<T> for WithType {
|
|
fn fmt(_: &T, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
fmt.write_str("*** ")?;
|
|
fmt.write_str(std::any::type_name::<T>())?;
|
|
fmt.write_str(" ***")
|
|
}
|
|
}
|
|
|
|
/// Debug without type
|
|
pub enum WithoutType {}
|
|
|
|
impl<T> Strategy<T> for WithoutType {
|
|
fn fmt(_: &T, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
fmt.write_str("*** ***")
|
|
}
|
|
}
|