pub struct Bech32String { /* private fields */ }Expand description
Validated Bech32/Bech32m string wrapper for secret data.
Implementations§
Source§impl Bech32String
impl Bech32String
Sourcepub fn new(s: String) -> Result<Self, &'static str>
pub fn new(s: String) -> Result<Self, &'static str>
Create a new Bech32String from a String, validating and normalizing it.
Accepts mixed-case input (normalized to lowercase for storage).
§Security Note
Invalid inputs are only securely zeroized if the zeroize feature is enabled.
Without zeroize, rejected bytes may remain in memory until the String is dropped
normally. Enable the zeroize feature for secure wiping of invalid inputs.
Sourcepub fn is_bech32m(&self) -> bool
pub fn is_bech32m(&self) -> bool
Check if this is a Bech32m encoding.
Sourcepub fn byte_len(&self) -> usize
pub fn byte_len(&self) -> usize
Exact number of bytes the decoded payload represents (allocation-free).
Sourcepub fn decode_to_bytes(&self) -> Vec<u8> ⓘ
pub fn decode_to_bytes(&self) -> Vec<u8> ⓘ
decode_to_bytes: borrowing, allocates fresh Vec<u8> from decoded bytes
Sourcepub fn variant(&self) -> EncodingVariant
pub fn variant(&self) -> EncodingVariant
Get the detected encoding variant.
Sourcepub fn decode_into_bytes(self) -> Vec<u8> ⓘ
pub fn decode_into_bytes(self) -> Vec<u8> ⓘ
decode_into_bytes: consuming, decodes then zeroizes the wrapper immediately
Trait Implementations§
Source§impl Debug for Bech32String
Debug implementation (always redacted).
impl Debug for Bech32String
Debug implementation (always redacted).
Source§impl ExposeSecret for Bech32String
Available on crate feature encoding-bech32 only.Implementation for Bech32String - read-only access.
impl ExposeSecret for Bech32String
encoding-bech32 only.Implementation for Bech32String - read-only access.
Encoding wrappers only provide read-only access to prevent invalidation of
validation invariants. The Inner type is str since encoded strings are
always valid UTF-8.
Source§impl PartialEq for Bech32String
Available on crate feature ct-eq only.Constant-time equality (prevents timing attacks when comparing encoded secrets).
impl PartialEq for Bech32String
ct-eq only.Constant-time equality (prevents timing attacks when comparing encoded secrets).
impl Eq for Bech32String
Equality implementation.