Skip to main content

SerializableSecret

Trait SerializableSecret 

Source
pub trait SerializableSecret: Serialize { }
Expand description

Implement this on types that can be deliberately serialized while maintaining security. The trait itself is a marker and does not provide methods, but implementations must ensure that serialization does not leak secrets unintentionally.

§Examples

use secure_gate::SerializableSecret;
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize)]
struct MySecret {
    data: Vec<u8>,
}

impl SerializableSecret for MySecret {}

// Now MySecret can be serialized securely, as it's marked with SerializableSecret

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§