Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

chore(masking): add peek_mut to PeekInterface (#7281)

Kartikeya Hegde890a265e7b1b
diff --git a/crates/masking/src/abs.rs b/crates/masking/src/abs.rs
index 6501f89c9d..8996db65f2 100644
--- a/crates/masking/src/abs.rs
+++ b/crates/masking/src/abs.rs
@@ -6,6 +6,9 @@ use crate::Secret;
pub trait PeekInterface<S> {
/// Only method providing access to the secret value.
fn peek(&self) -> &S;
+
+ /// Provide a mutable reference to the inner value.
+ fn peek_mut(&mut self) -> &mut S;
}
/// Interface that consumes a option secret and returns the value.
diff --git a/crates/masking/src/bytes.rs b/crates/masking/src/bytes.rs
index e828f8a78e..07b8c289ad 100644
--- a/crates/masking/src/bytes.rs
+++ b/crates/masking/src/bytes.rs
@@ -28,6 +28,10 @@ impl PeekInterface<BytesMut> for SecretBytesMut {
fn peek(&self) -> &BytesMut {
&self.0
}
+
+ fn peek_mut(&mut self) -> &mut BytesMut {
+ &mut self.0
+ }
}
impl fmt::Debug for SecretBytesMut {
diff --git a/crates/masking/src/secret.rs b/crates/masking/src/secret.rs
index 7f7c18094a..ee65b1c015 100644
--- a/crates/masking/src/secret.rs
+++ b/crates/masking/src/secret.rs
@@ -95,6 +95,10 @@ where
fn peek(&self) -> &SecretValue {
&self.inner_secret
}
+
+ fn peek_mut(&mut self) -> &mut SecretValue {
+ &mut self.inner_secret
+ }
}
impl<SecretValue, MaskingStrategy> From<SecretValue> for Secret<SecretValue, MaskingStrategy>
diff --git a/crates/masking/src/strong_secret.rs b/crates/masking/src/strong_secret.rs
index 300b5463d2..43d2c97dfb 100644
--- a/crates/masking/src/strong_secret.rs
+++ b/crates/masking/src/strong_secret.rs
@@ -32,6 +32,10 @@ impl<Secret: ZeroizableSecret, MaskingStrategy> PeekInterface<Secret>
fn peek(&self) -> &Secret {
&self.inner_secret
}
+
+ fn peek_mut(&mut self) -> &mut Secret {
+ &mut self.inner_secret
+ }
}
impl<Secret: ZeroizableSecret, MaskingStrategy> From<Secret>