Skip to main content

secure_gate/traits/
serializable_secret.rs

1//! Marker trait for opt-in serialization of raw secrets.
2
3/// Implement this on types that can be deliberately serialized while maintaining security.
4/// The trait itself is a marker and does not provide methods, but implementations must
5/// ensure that serialization does not leak secrets unintentionally.
6///
7/// # Examples
8///
9/// ```rust
10/// # #[cfg(feature = "serde-serialize")]
11/// # {
12/// use secure_gate::SerializableSecret;
13/// use serde::{Deserialize, Serialize};
14///
15/// #[derive(Serialize, Deserialize)]
16/// struct MySecret {
17///     data: Vec<u8>,
18/// }
19///
20/// impl SerializableSecret for MySecret {}
21///
22/// // Now MySecret can be serialized securely, as it's marked with SerializableSecret
23/// # }
24/// ```
25#[cfg(feature = "serde-serialize")]
26pub trait SerializableSecret: serde::Serialize {}