pub struct Unredacted<T>(pub T);Expand description
Wrapper that opts a value in to formatting or serialization that would otherwise expose private-key bytes.
Wrap an ed25519::PrivateKey in Unredacted
for any of:
Display/to_string/write_string— renders the encoded strkey string (S…).Debug— prints the raw 32-byte seed as hex (PrivateKey(<hex>)). BarePrivateKey’sDebugredacts.serde::Serialize(under theserdefeature) — serializes as the strkey string form.Decoded<Unredacted<&PrivateKey>>(under theserde-decodedfeature) — serializes the raw seed as hex inside a JSON object.
§Zeroize
Display, to_string, and serde::Serialize materialize the encoded
bytes into a non-zeroizing intermediate (the returned String, the
formatter, or the serializer’s internal buffer). For the strongest
guarantees, use Unredacted::write_string to write directly into a
caller-provided Zeroizing buffer.
Tuple Fields§
§0: TImplementations§
Source§impl Unredacted<&PrivateKey>
impl Unredacted<&PrivateKey>
Sourcepub fn to_string(&self) -> String<{ PrivateKey::ENCODED_LEN }>
pub fn to_string(&self) -> String<{ PrivateKey::ENCODED_LEN }>
Encodes this private key to its strkey string form.
§Zeroize
The intermediate scratch buffers used during encoding are zeroed on
drop, but the returned String itself is plain — its bytes are not
zeroed when the value is dropped. Use
write_string for zeroizing.
Sourcepub fn write_string(
&self,
out: &mut Zeroizing<String<{ PrivateKey::ENCODED_LEN }>>,
)
pub fn write_string( &self, out: &mut Zeroizing<String<{ PrivateKey::ENCODED_LEN }>>, )
Encodes this private key to its strkey string form, writing the result into the caller-provided buffer.
§Zeroize
The intermediate scratch buffers used during encoding are wrapped in
Zeroizing and zeroed on drop, and the encoded bytes are written
directly into out rather than returned by value, so no copy is left
on this method’s stack frame.
Trait Implementations§
Source§impl<T: Clone> Clone for Unredacted<T>
impl<T: Clone> Clone for Unredacted<T>
Source§fn clone(&self) -> Unredacted<T>
fn clone(&self) -> Unredacted<T>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl<T: Copy> Copy for Unredacted<T>
Source§impl Debug for Unredacted<&PrivateKey>
impl Debug for Unredacted<&PrivateKey>
Source§impl Debug for Unredacted<PrivateKey>
impl Debug for Unredacted<PrivateKey>
Source§impl Display for Unredacted<&PrivateKey>
impl Display for Unredacted<&PrivateKey>
Source§impl Display for Unredacted<PrivateKey>
impl Display for Unredacted<PrivateKey>
impl<T: Eq> Eq for Unredacted<T>
Source§impl<T: Hash> Hash for Unredacted<T>
impl<T: Hash> Hash for Unredacted<T>
Source§impl<T: Ord> Ord for Unredacted<T>
impl<T: Ord> Ord for Unredacted<T>
Source§fn cmp(&self, other: &Unredacted<T>) -> Ordering
fn cmp(&self, other: &Unredacted<T>) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<T: PartialEq> PartialEq for Unredacted<T>
impl<T: PartialEq> PartialEq for Unredacted<T>
Source§fn eq(&self, other: &Unredacted<T>) -> bool
fn eq(&self, other: &Unredacted<T>) -> bool
self and other values to be equal, and is used by ==.