Skip to content

Commit

Permalink
impl FromStr for elfo::config::Secret (#135)
Browse files Browse the repository at this point in the history
feat(config/secret): impl FromStr
  • Loading branch information
RGafiyatullin authored Aug 24, 2024
1 parent 0f43874 commit 2e4e6d9
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions elfo-core/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use std::{
any::{Any, TypeId},
fmt, mem,
ops::Deref,
str::FromStr,
sync::Arc,
};

Expand Down Expand Up @@ -286,6 +287,14 @@ impl<T> fmt::Display for Secret<T> {
}
}

impl<T: FromStr> FromStr for Secret<T> {
type Err = T::Err;

fn from_str(s: &str) -> Result<Self, Self::Err> {
T::from_str(s).map(Self)
}
}

impl<'de, T: Deserialize<'de>> Deserialize<'de> for Secret<T> {
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
T::deserialize(deserializer).map(Self)
Expand Down

0 comments on commit 2e4e6d9

Please sign in to comment.