Skip to main content

Zeroizing

Struct Zeroizing 

Source
pub struct Zeroizing<Z>(/* private fields */)
where
    Z: Zeroize;
Expand description

Zeroizing is a a wrapper for any Z: Zeroize type which implements a Drop handler which zeroizes dropped values.

Implementations§

Source§

impl<Z> Zeroizing<Z>
where Z: Zeroize,

Source

pub fn new(value: Z) -> Zeroizing<Z>

Move value inside a Zeroizing wrapper which ensures it will be zeroized when it’s dropped.

Trait Implementations§

Source§

impl<T, Z> AsMut<T> for Zeroizing<Z>
where Z: AsMut<T> + Zeroize, T: ?Sized,

Source§

fn as_mut(&mut self) -> &mut T

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<T, Z> AsRef<T> for Zeroizing<Z>
where Z: AsRef<T> + Zeroize, T: ?Sized,

Source§

fn as_ref(&self) -> &T

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<Z> Borrow<[u8]> for Zeroizing<Z>
where Z: Borrow<[u8]> + Zeroize,

Source§

fn borrow(&self) -> &[u8]

Immutably borrows from an owned value. Read more
Source§

impl<const N: usize, Z> Borrow<[u8; N]> for Zeroizing<Z>
where Z: Borrow<[u8; N]> + Zeroize,

Source§

fn borrow(&self) -> &[u8; N]

Immutably borrows from an owned value. Read more
Source§

impl<N> Borrow<GenericArray<u8, N>> for Zeroizing<GenericArray<u8, N>>
where N: ArrayLength,

Source§

fn borrow(&self) -> &GenericArray<u8, N>

Immutably borrows from an owned value. Read more
Source§

impl<Z> BorrowMut<[u8]> for Zeroizing<Z>
where Z: BorrowMut<[u8]> + Zeroize,

Source§

fn borrow_mut(&mut self) -> &mut [u8]

Mutably borrows from an owned value. Read more
Source§

impl<const N: usize, Z> BorrowMut<[u8; N]> for Zeroizing<Z>
where Z: BorrowMut<[u8; N]> + Zeroize,

Source§

fn borrow_mut(&mut self) -> &mut [u8; N]

Mutably borrows from an owned value. Read more
Source§

impl<N> BorrowMut<GenericArray<u8, N>> for Zeroizing<GenericArray<u8, N>>
where N: ArrayLength,

Source§

fn borrow_mut(&mut self) -> &mut GenericArray<u8, N>

Mutably borrows from an owned value. Read more
Source§

impl<Z> Clone for Zeroizing<Z>
where Z: Zeroize + Clone,

Source§

fn clone(&self) -> Zeroizing<Z>

Returns a duplicate of the value. Read more
Source§

fn clone_from(&mut self, source: &Zeroizing<Z>)

Performs copy-assignment from source. Read more
Source§

impl<Z> Debug for Zeroizing<Z>
where Z: Debug + Zeroize,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<Z> Default for Zeroizing<Z>
where Z: Default + Zeroize,

Source§

fn default() -> Zeroizing<Z>

Returns the “default value” for a type. Read more
Source§

impl<Z> Deref for Zeroizing<Z>
where Z: Zeroize,

Source§

type Target = Z

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Z

Dereferences the value.
Source§

impl<Z> DerefMut for Zeroizing<Z>
where Z: Zeroize,

Source§

fn deref_mut(&mut self) -> &mut Z

Mutably dereferences the value.
Source§

impl<Z> Drop for Zeroizing<Z>
where Z: Zeroize,

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<Z> From<Z> for Zeroizing<Z>
where Z: Zeroize,

Source§

fn from(value: Z) -> Zeroizing<Z>

Converts to this type from the input type.
Source§

impl<Z> PartialEq for Zeroizing<Z>
where Z: PartialEq + Zeroize,

Source§

fn eq(&self, other: &Zeroizing<Z>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<Z> Zeroize for Zeroizing<Z>
where Z: Zeroize,

Source§

fn zeroize(&mut self)

Zero out this object from memory using Rust intrinsics which ensure the zeroization operation is not “optimized away” by the compiler.
Source§

impl<Z> Eq for Zeroizing<Z>
where Z: Eq + Zeroize,

Source§

impl<Z> StructuralPartialEq for Zeroizing<Z>
where Z: Zeroize,

Source§

impl<Z> ZeroizeOnDrop for Zeroizing<Z>
where Z: Zeroize,

Auto Trait Implementations§

§

impl<Z> Freeze for Zeroizing<Z>
where Z: Freeze,

§

impl<Z> RefUnwindSafe for Zeroizing<Z>
where Z: RefUnwindSafe,

§

impl<Z> Send for Zeroizing<Z>
where Z: Send,

§

impl<Z> Sync for Zeroizing<Z>
where Z: Sync,

§

impl<Z> Unpin for Zeroizing<Z>
where Z: Unpin,

§

impl<Z> UnsafeUnpin for Zeroizing<Z>
where Z: UnsafeUnpin,

§

impl<Z> UnwindSafe for Zeroizing<Z>
where Z: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<I> IdExt for I
where [u8; 32]: Into<I>,

Source§

fn new<'a, CS>( tag: &'static [u8], data: impl IntoIterator<Item = &'a [u8]>, ) -> I
where CS: CipherSuite,

Derives an ID from the hash of some data.
Source§

fn random<R>(rng: R) -> I
where R: Csprng,

Creates a random ID.
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
Source§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

Source§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
Source§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The metadata type for pointers and references to this type.
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<R> Rng for R
where R: RngCore + ?Sized,

Source§

fn random<T>(&mut self) -> T

Return a random value via the StandardUniform distribution. Read more
Source§

fn random_iter<T>(self) -> Iter<StandardUniform, Self, T>

Return an iterator over random variates Read more
Source§

fn random_range<T, R>(&mut self, range: R) -> T
where T: SampleUniform, R: SampleRange<T>,

Generate a random value in the given range. Read more
Source§

fn random_bool(&mut self, p: f64) -> bool

Return a bool with a probability p of being true. Read more
Source§

fn random_ratio(&mut self, numerator: u32, denominator: u32) -> bool

Return a bool with a probability of numerator/denominator of being true. Read more
Source§

fn sample<T, D>(&mut self, distr: D) -> T
where D: Distribution<T>,

Sample a new value, using the given distribution. Read more
Source§

fn sample_iter<T, D>(self, distr: D) -> Iter<D, Self, T>
where D: Distribution<T>, Self: Sized,

Create an iterator that generates values using the given distribution. Read more
Source§

fn fill<T>(&mut self, dest: &mut T)
where T: Fill + ?Sized,

Fill any type implementing Fill with random data Read more
Source§

fn gen<T>(&mut self) -> T

👎Deprecated since 0.9.0: Renamed to random to avoid conflict with the new gen keyword in Rust 2024.
Alias for Rng::random.
Source§

fn gen_range<T, R>(&mut self, range: R) -> T
where T: SampleUniform, R: SampleRange<T>,

👎Deprecated since 0.9.0: Renamed to random_range
Source§

fn gen_bool(&mut self, p: f64) -> bool

👎Deprecated since 0.9.0: Renamed to random_bool
Alias for Rng::random_bool.
Source§

fn gen_ratio(&mut self, numerator: u32, denominator: u32) -> bool

👎Deprecated since 0.9.0: Renamed to random_ratio
Source§

impl<T> RngCore for T
where T: DerefMut, <T as Deref>::Target: RngCore,

Source§

fn next_u32(&mut self) -> u32

Return the next random u32. Read more
Source§

fn next_u64(&mut self) -> u64

Return the next random u64. Read more
Source§

fn fill_bytes(&mut self, dst: &mut [u8])

Fill dest with random data. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToHex for T
where T: AsRef<[u8]>,

Source§

type Output = T

A hexadecimal string.
Source§

fn to_hex(self) -> Hex<<T as ToHex>::Output>

Encodes itself as a hexadecimal string.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<R> TryRngCore for R
where R: RngCore + ?Sized,

Source§

type Error = Infallible

The type returned in the event of a RNG error.
Source§

fn try_next_u32(&mut self) -> Result<u32, <R as TryRngCore>::Error>

Return the next random u32.
Source§

fn try_next_u64(&mut self) -> Result<u64, <R as TryRngCore>::Error>

Return the next random u64.
Source§

fn try_fill_bytes( &mut self, dst: &mut [u8], ) -> Result<(), <R as TryRngCore>::Error>

Fill dest entirely with random data.
Source§

fn unwrap_err(self) -> UnwrapErr<Self>
where Self: Sized,

Wrap RNG with the UnwrapErr wrapper.
Source§

fn unwrap_mut(&mut self) -> UnwrapMut<'_, Self>

Wrap RNG with the UnwrapMut wrapper.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> CryptoRng for T
where T: DerefMut, <T as Deref>::Target: CryptoRng,

Source§

impl<R> TryCryptoRng for R
where R: CryptoRng + ?Sized,