pub struct Dynamic<T: ?Sized> { /* private fields */ }Expand description
Re-export of the Dynamic type.
Dynamic-sized heap-allocated secure secret wrapper.
This is a thin wrapper around Box<T> with enforced explicit exposure.
Suitable for dynamic-sized secrets like String or Vec<u8>.
The inner field is private, forcing all access through explicit methods.
Security invariants:
- No
DereforAsRef— prevents silent access. Debugis always redacted.- With
zeroize, wipes the entire allocation on drop (including spare capacity).
Implementations§
impl Dynamic<String>
This impl block contains no items.
§Ergonomic helpers for common heap types
Source§impl Dynamic<Vec<u8>>
impl Dynamic<Vec<u8>>
Sourcepub fn from_random(len: usize) -> Self
pub fn from_random(len: usize) -> Self
Fill with fresh random bytes of the specified length using the System RNG.
Panics on RNG failure for fail-fast crypto code. Guarantees secure entropy from system sources.
Source§impl Dynamic<Vec<u8>>
impl Dynamic<Vec<u8>>
Sourcepub fn try_from_base64url(s: &str) -> Result<Self, Base64Error>
pub fn try_from_base64url(s: &str) -> Result<Self, Base64Error>
Decode a base64url string into a Dynamic secret.
§Example
use secure_gate::{Dynamic, ExposeSecret};
let b64_string = "QkNE";
let secret = Dynamic::try_from_base64url(b64_string).unwrap();
assert_eq!(secret.expose_secret().len(), 3);Source§impl Dynamic<Vec<u8>>
impl Dynamic<Vec<u8>>
Sourcepub fn try_from_bech32(s: &str) -> Result<Self, Bech32Error>
pub fn try_from_bech32(s: &str) -> Result<Self, Bech32Error>
Decode a bech32 string into a Dynamic secret, discarding the HRP.
§Example
use secure_gate::{Dynamic, ExposeSecret, ToBech32};
let original: Dynamic<Vec<u8>> = Dynamic::new(vec![1, 2, 3, 4]);
let bech32_string = original.with_secret(|s| s.to_bech32("test"));
let decoded = Dynamic::try_from_bech32(&bech32_string).unwrap();
// HRP "test" is discarded, bytes are storedSource§impl Dynamic<Vec<u8>>
impl Dynamic<Vec<u8>>
Sourcepub fn try_from_bech32m(s: &str) -> Result<Self, Bech32Error>
pub fn try_from_bech32m(s: &str) -> Result<Self, Bech32Error>
Decode a bech32m string into a Dynamic secret, discarding the HRP.
§Example
use secure_gate::Dynamic;
// Note: Bech32m strings must be valid Bech32m format
let bech32m_string = "abc1qpzry9x8gf2tvdw0s3jn54khce6mua7lmqqqxw";
let secret = Dynamic::try_from_bech32m(bech32m_string);
// Returns Result<Dynamic<Vec<u8>>, Bech32Error>Trait Implementations§
Source§impl<T: CloneableType> Clone for Dynamic<T>
Available on crate feature cloneable only.
impl<T: CloneableType> Clone for Dynamic<T>
Available on crate feature
cloneable only.Source§impl<T> ConstantTimeEq for Dynamic<T>where
T: ConstantTimeEq + ?Sized,
Available on crate feature ct-eq only.
impl<T> ConstantTimeEq for Dynamic<T>where
T: ConstantTimeEq + ?Sized,
Available on crate feature
ct-eq only.Source§impl<T> ConstantTimeEqExt for Dynamic<T>
Available on crate feature ct-eq-hash only.
impl<T> ConstantTimeEqExt for Dynamic<T>
Available on crate feature
ct-eq-hash only.Source§fn ct_eq_hash(&self, other: &Self) -> bool
fn ct_eq_hash(&self, other: &Self) -> bool
Force BLAKE3 digest comparison (constant-time on 32-byte output). Read more
Source§impl<'de> Deserialize<'de> for Dynamic<String>
Available on crate feature serde-deserialize only.
impl<'de> Deserialize<'de> for Dynamic<String>
Available on crate feature
serde-deserialize only.Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<'de> Deserialize<'de> for Dynamic<Vec<u8>>
Available on crate feature serde-deserialize only.
impl<'de> Deserialize<'de> for Dynamic<Vec<u8>>
Available on crate feature
serde-deserialize only.Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl ExposeSecret for Dynamic<String>
impl ExposeSecret for Dynamic<String>
Source§fn with_secret<F, R>(&self, f: F) -> R
fn with_secret<F, R>(&self, f: F) -> R
Provide scoped read-only access to the secret. Read more
Source§fn expose_secret(&self) -> &String
fn expose_secret(&self) -> &String
Expose the secret for read-only access. Read more
Source§impl<T> ExposeSecret for Dynamic<Vec<T>>
impl<T> ExposeSecret for Dynamic<Vec<T>>
Source§fn with_secret<F, R>(&self, f: F) -> R
fn with_secret<F, R>(&self, f: F) -> R
Provide scoped read-only access to the secret. Read more
Source§fn expose_secret(&self) -> &Vec<T>
fn expose_secret(&self) -> &Vec<T>
Expose the secret for read-only access. Read more
Source§impl ExposeSecretMut for Dynamic<String>
impl ExposeSecretMut for Dynamic<String>
Source§impl<T> ExposeSecretMut for Dynamic<Vec<T>>
impl<T> ExposeSecretMut for Dynamic<Vec<T>>
Source§impl<T> Serialize for Dynamic<T>where
T: SerializableType,
Available on crate feature serde-serialize only.
impl<T> Serialize for Dynamic<T>where
T: SerializableType,
Available on crate feature
serde-serialize only.impl<T: ?Sized + Zeroize> ZeroizeOnDrop for Dynamic<T>
Available on crate feature
zeroize only.Zeroize on drop integration
Auto Trait Implementations§
impl<T> Freeze for Dynamic<T>where
T: ?Sized,
impl<T> RefUnwindSafe for Dynamic<T>where
T: RefUnwindSafe + ?Sized,
impl<T> Send for Dynamic<T>
impl<T> Sync for Dynamic<T>
impl<T> Unpin for Dynamic<T>where
T: ?Sized,
impl<T> UnwindSafe for Dynamic<T>where
T: UnwindSafe + ?Sized,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more