Skip to main content

CloneableType

Trait CloneableType 

Source
pub trait CloneableType: Clone { }
Expand description

Implement this trait on types that require safe duplication while maintaining security guarantees. The trait itself is a marker and does not provide methods, but implementations must ensure proper zeroization.

§Examples

#[cfg(feature = "cloneable")]
{
    use secure_gate::{CloneableType, Fixed};

    #[derive(Clone)]
    struct MyKey([u8; 32]);

    impl CloneableType for MyKey {}  // Opt-in to safe cloning

    let key: Fixed<MyKey> = Fixed::new(MyKey([0; 32]));
    let copy = key.clone();  // Now allowed, with zeroization on drop
}

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§