From d5121025e4d3043f949edc18c96111a55cdf6250 Mon Sep 17 00:00:00 2001 From: Mykhailo Lohachov Date: Thu, 12 Dec 2024 11:45:14 +0900 Subject: [PATCH] fix: Make SecretString public (#5269) * fix: make secret string public Signed-off-by: Lohachov Mykhailo * fix: Update crates/iroha/src/secrecy.rs Co-authored-by: Shunkichi Sato <49983831+s8sato@users.noreply.github.com> Signed-off-by: Mykhailo Lohachov --------- Signed-off-by: Lohachov Mykhailo Signed-off-by: Mykhailo Lohachov Co-authored-by: Shunkichi Sato <49983831+s8sato@users.noreply.github.com> --- crates/iroha/src/lib.rs | 2 +- crates/iroha/src/secrecy.rs | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/iroha/src/lib.rs b/crates/iroha/src/lib.rs index 02c3553fb1d..fe29f02d3fd 100644 --- a/crates/iroha/src/lib.rs +++ b/crates/iroha/src/lib.rs @@ -5,7 +5,7 @@ pub mod config; pub mod http; mod http_default; pub mod query; -mod secrecy; +pub mod secrecy; pub use iroha_crypto as crypto; pub use iroha_data_model as data_model; diff --git a/crates/iroha/src/secrecy.rs b/crates/iroha/src/secrecy.rs index cdba906f476..08036233318 100644 --- a/crates/iroha/src/secrecy.rs +++ b/crates/iroha/src/secrecy.rs @@ -1,12 +1,15 @@ +//! Types for representing securely printable secrets. use std::fmt; use derive_more::Constructor; use serde::{Deserialize, Serialize, Serializer}; +/// String sensitive to printing and serialization #[derive(Clone, Deserialize, Constructor)] pub struct SecretString(String); impl SecretString { + /// Returns underlying secret string pub fn expose_secret(&self) -> &str { &self.0 }