secure_gate/traits/decoding/mod.rs
1//! Decoding traits for explicit string-to-bytes conversion.
2//!
3//! > **Import paths:** `use secure_gate::FromHexStr;` etc. (not `secure_gate::traits::decoding::hex::FromHexStr`)
4//!
5//! All decoding traits return `Vec<u8>` (require `alloc`). For no-alloc targets, use
6//! `Fixed::try_from_hex`, `Fixed::try_from_base32`, `Fixed::try_from_base64url`, etc. — these
7//! decode directly into a stack-allocated buffer. Treat all input as untrusted. Prefer
8//! HRP-validated bech32 methods.
9//! See the [`encoding`](super::encoding) module for the reverse direction.
10//!
11//! Each decoding trait has its own feature gate:
12//!
13//! | Trait | Feature |
14//! |---------------------|---------------------|
15//! | [`FromHexStr`] | `encoding-hex` |
16//! | [`FromBase32Str`] | `encoding-base32` |
17//! | [`FromBase64UrlStr`]| `encoding-base64` |
18//! | [`FromBech32Str`] | `encoding-bech32` |
19//! | [`FromBech32mStr`] | `encoding-bech32` |
20pub mod base32;
21pub mod base64_url;
22pub mod bech32;
23#[cfg(feature = "encoding-bech32")]
24pub mod bech32m;
25pub mod hex;
26
27#[cfg(all(feature = "encoding-base32", feature = "alloc"))]
28pub use base32::FromBase32Str;
29#[cfg(all(feature = "encoding-base64", feature = "alloc"))]
30pub use base64_url::FromBase64UrlStr;
31#[cfg(all(feature = "encoding-bech32", feature = "alloc"))]
32pub use bech32::FromBech32Str;
33#[cfg(all(feature = "encoding-bech32", feature = "alloc"))]
34pub use bech32m::FromBech32mStr;
35#[cfg(all(feature = "encoding-hex", feature = "alloc"))]
36pub use hex::FromHexStr;