Trait ProtectedInitSlice

Source
pub trait ProtectedInitSlice:
    ExposeProtected<Target = [Self::Item]>
    + From<SecureBox<[Self::Item]>>
    + Sized {
    type Item;

    // Provided methods
    fn init_slice<F>(len: usize, f: F) -> Self
       where F: FnOnce(SecureRef<&mut [Self::Item]>),
             Self::Item: Copy + FillBytes { ... }
    fn init_default_slice<F>(len: usize, f: F) -> Self
       where F: FnOnce(SecureRef<&mut [Self::Item]>),
             Self::Item: Default { ... }
    fn init_random_slice<F>(len: usize, rng: impl RngCore, f: F) -> Self
       where F: FnOnce(SecureRef<&mut [Self::Item]>),
             Self::Item: Copy + FillBytes { ... }
    fn init_take_slice<F>(from: &mut [Self::Item], f: F) -> Self
       where F: FnOnce(SecureRef<&mut [Self::Item]>),
             Self::Item: DefaultIsZeroes { ... }
    fn random_slice(len: usize, rng: impl RngCore) -> Self
       where Self::Item: Copy + FillBytes { ... }
    fn take_slice(from: &mut [Self::Item]) -> Self
       where Self::Item: DefaultIsZeroes { ... }
}
Expand description

Initialize a protected container type for a slice of elements.

Required Associated Types§

Source

type Item

The type of the elements contained in the slice.

Provided Methods§

Source

fn init_slice<F>(len: usize, f: F) -> Self
where F: FnOnce(SecureRef<&mut [Self::Item]>), Self::Item: Copy + FillBytes,

For a concrete type implementing FillBytes, initialize a slice of length len with the standard indicator value and call the closure f with a mutable reference to the slice before applying protections.

Source

fn init_default_slice<F>(len: usize, f: F) -> Self
where F: FnOnce(SecureRef<&mut [Self::Item]>), Self::Item: Default,

Initialize with a slice of length len containing the default value for Self::Item, and call the closure f with a mutable reference to the slice before applying protections.

Source

fn init_random_slice<F>(len: usize, rng: impl RngCore, f: F) -> Self
where F: FnOnce(SecureRef<&mut [Self::Item]>), Self::Item: Copy + FillBytes,

Initialize with a randomized slice of length len, and call the closure f with a mutable reference to the slice before applying protections.

Source

fn init_take_slice<F>(from: &mut [Self::Item], f: F) -> Self
where F: FnOnce(SecureRef<&mut [Self::Item]>), Self::Item: DefaultIsZeroes,

Initialize by copying the slice from and zeroizing the existing copy. Call the closure f with a mutable reference to the contained slice before applying protections.

Source

fn random_slice(len: usize, rng: impl RngCore) -> Self
where Self::Item: Copy + FillBytes,

Create a new protected instance containing a random slice of length len.

Source

fn take_slice(from: &mut [Self::Item]) -> Self
where Self::Item: DefaultIsZeroes,

Create a new protected slice instance by copying and zeroizing an existing slice.

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§

Source§

impl<T, W> ProtectedInitSlice for W
where W: From<SecureBox<[T]>> + ExposeProtected<Target = [T]>,

Source§

type Item = T