Skip to main content

secure_gate/traits/encoding/
mod.rs

1//! Encoding traits for explicit secret-to-string conversion.
2//!
3//! > **Import paths:** `use secure_gate::ToHex;` etc. (not `secure_gate::traits::encoding::hex::ToHex`)
4//!
5//! All encoding traits require `alloc` (they return `String` or [`EncodedSecret`](crate::EncodedSecret)).
6//! Prefer zeroizing variants (`*_zeroizing`) when the encoded form is sensitive.
7//! See the [`decoding`](super::decoding) module for the reverse direction.
8//!
9//! Each encoding trait has its own feature gate:
10//!
11//! | Trait            | Feature             |
12//! |------------------|---------------------|
13//! | [`ToHex`]        | `encoding-hex`      |
14//! | [`ToBase64Url`]  | `encoding-base64`   |
15//! | [`ToBech32`]     | `encoding-bech32`   |
16//! | [`ToBech32m`]    | `encoding-bech32m`  |
17pub mod base64_url;
18pub mod bech32;
19#[cfg(feature = "encoding-bech32m")]
20pub mod bech32m;
21pub mod hex;
22
23// Encoding traits produce String / EncodedSecret — all require alloc
24#[cfg(all(feature = "encoding-base64", feature = "alloc"))]
25pub use base64_url::ToBase64Url;
26#[cfg(all(feature = "encoding-bech32", feature = "alloc"))]
27pub use bech32::ToBech32;
28#[cfg(all(feature = "encoding-bech32m", feature = "alloc"))]
29pub use bech32m::ToBech32m;
30#[cfg(all(feature = "encoding-hex", feature = "alloc"))]
31pub use hex::ToHex;