mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-01 02:57:02 +08:00
initial commit
This commit is contained in:
39
crates/masking/src/string.rs
Normal file
39
crates/masking/src/string.rs
Normal file
@ -0,0 +1,39 @@
|
||||
//!
|
||||
//! Secret strings
|
||||
//!
|
||||
//! There is not alias type by design.
|
||||
|
||||
use alloc::{
|
||||
str::FromStr,
|
||||
string::{String, ToString},
|
||||
};
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
use super::SerializableSecret;
|
||||
use super::{Secret, Strategy};
|
||||
use crate::StrongSecret;
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
impl SerializableSecret for String {}
|
||||
|
||||
impl<I> FromStr for Secret<String, I>
|
||||
where
|
||||
I: Strategy<String>,
|
||||
{
|
||||
type Err = core::convert::Infallible;
|
||||
|
||||
fn from_str(src: &str) -> Result<Self, Self::Err> {
|
||||
Ok(Secret::<String, I>::new(src.to_string()))
|
||||
}
|
||||
}
|
||||
|
||||
impl<I> FromStr for StrongSecret<String, I>
|
||||
where
|
||||
I: Strategy<String>,
|
||||
{
|
||||
type Err = core::convert::Infallible;
|
||||
|
||||
fn from_str(src: &str) -> Result<Self, Self::Err> {
|
||||
Ok(StrongSecret::<String, I>::new(src.to_string()))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user