Trait sgx_tstd::marker::Unpin

1.33.0 · source · []
pub auto trait Unpin { }
Expand description

Types that can be safely moved after being pinned.

Rust itself has no notion of immovable types, and considers moves (e.g., through assignment or mem::replace) to always be safe.

The Pin type is used instead to prevent moves through the type system. Pointers P<T> wrapped in the Pin<P<T>> wrapper can’t be moved out of. See the pin module documentation for more information on pinning.

Implementing the Unpin trait for T lifts the restrictions of pinning off the type, which then allows moving T out of Pin<P<T>> with functions such as mem::replace.

Unpin has no consequence at all for non-pinned data. In particular, mem::replace happily moves !Unpin data (it works for any &mut T, not just when T: Unpin). However, you cannot use mem::replace on data wrapped inside a Pin<P<T>> because you cannot get the &mut T you need for that, and that is what makes this system work.

So this, for example, can only be done on types implementing Unpin:

use std::mem;
use std::pin::Pin;

let mut string = "this".to_string();
let mut pinned_string = Pin::new(&mut string);

// We need a mutable reference to call `mem::replace`.
// We can obtain such a reference by (implicitly) invoking `Pin::deref_mut`,
// but that is only possible because `String` implements `Unpin`.
mem::replace(&mut *pinned_string, "other".to_string());

This trait is automatically implemented for almost every type.

Implementors

Auto implementors

impl<K, V, S, A> Unpin for HashMap<K, V, S, A>where
    A: Unpin,
    K: Unpin,
    S: Unpin,
    V: Unpin,

impl<'a, K, V> Unpin for Iter<'a, K, V>

impl<'a, K, V> Unpin for IterMut<'a, K, V>

impl<K, V, A> Unpin for IntoIter<K, V, A>where
    A: Unpin,
    K: Unpin,
    V: Unpin,

impl<K, V, A> Unpin for IntoKeys<K, V, A>where
    A: Unpin,
    K: Unpin,
    V: Unpin,

impl<K, V, A> Unpin for IntoValues<K, V, A>where
    A: Unpin,
    K: Unpin,
    V: Unpin,

impl<'a, K, V> Unpin for Keys<'a, K, V>

impl<'a, K, V> Unpin for Values<'a, K, V>

impl<'a, K, V, A> Unpin for Drain<'a, K, V, A>where
    A: Unpin,
    K: Unpin,
    V: Unpin,

impl<'a, K, V, F, A> Unpin for DrainFilter<'a, K, V, F, A>where
    F: Unpin,

impl<'a, K, V> Unpin for ValuesMut<'a, K, V>

impl<'a, K, V, S, A> Unpin for RawEntryBuilderMut<'a, K, V, S, A>

impl<'a, K, V, S, A> Unpin for RawEntryMut<'a, K, V, S, A>

impl<'a, K, V, S, A> Unpin for RawOccupiedEntryMut<'a, K, V, S, A>

impl<'a, K, V, S, A> Unpin for RawVacantEntryMut<'a, K, V, S, A>

impl<'a, K, V, S, A> Unpin for RawEntryBuilder<'a, K, V, S, A>

impl<'a, K, V, S, A> Unpin for Entry<'a, K, V, S, A>where
    K: Unpin,

impl<'a, K, V, S, A> Unpin for OccupiedEntry<'a, K, V, S, A>where
    K: Unpin,

impl<'a, K, V, S, A> Unpin for VacantEntry<'a, K, V, S, A>where
    K: Unpin,

impl<'a, 'b, K, Q: ?Sized, V, S, A> Unpin for EntryRef<'a, 'b, K, Q, V, S, A>where
    K: Unpin,

impl<'a, 'b, K, Q: ?Sized, V, S, A> Unpin for OccupiedEntryRef<'a, 'b, K, Q, V, S, A>where
    K: Unpin,

impl<'a, 'b, K, Q: ?Sized, V, S, A> Unpin for VacantEntryRef<'a, 'b, K, Q, V, S, A>where
    K: Unpin,

impl<'a, K, V, S, A> Unpin for OccupiedError<'a, K, V, S, A>where
    K: Unpin,
    V: Unpin,

impl<'a, K, V, A> Unpin for RustcEntry<'a, K, V, A>where
    K: Unpin,

impl<'a, K, V, A> Unpin for RustcOccupiedEntry<'a, K, V, A>where
    K: Unpin,

impl<'a, K, V, A> Unpin for RustcVacantEntry<'a, K, V, A>where
    K: Unpin,

impl<T, S, A> Unpin for HashSet<T, S, A>where
    A: Unpin,
    S: Unpin,
    T: Unpin,

impl<'a, K> Unpin for Iter<'a, K>

impl<K, A> Unpin for IntoIter<K, A>where
    A: Unpin,
    K: Unpin,

impl<'a, K, A> Unpin for Drain<'a, K, A>where
    A: Unpin,
    K: Unpin,

impl<'a, K, F, A> Unpin for DrainFilter<'a, K, F, A>where
    F: Unpin,

impl<'a, T, S, A> Unpin for Intersection<'a, T, S, A>

impl<'a, T, S, A> Unpin for Difference<'a, T, S, A>

impl<'a, T, S, A> Unpin for SymmetricDifference<'a, T, S, A>

impl<'a, T, S, A> Unpin for Union<'a, T, S, A>

impl Unpin for AesCbc

impl Unpin for Nonce

impl<A> Unpin for AesCcm<A>where
    A: Unpin,

impl<A> Unpin for Aad<A>where
    A: Unpin,

impl Unpin for Nonce

impl Unpin for AesCtr

impl Unpin for Counter

impl<A> Unpin for AesGcm<A>where
    A: Unpin,

impl<A> Unpin for Aad<A>where
    A: Unpin,

impl Unpin for Nonce

impl Unpin for EcKeyPair

impl Unpin for EcShareKey

impl Unpin for AesCMac

impl Unpin for HashType

impl Unpin for HMac

impl Unpin for Sha1

impl Unpin for Sha256

impl Unpin for Sha384

impl Unpin for Sm2KeyPair

impl Unpin for Sm3

impl Unpin for Sm4Cbc

impl Unpin for Nonce

impl<A> Unpin for Sm4Ccm<A>where
    A: Unpin,

impl<A> Unpin for Aad<A>where
    A: Unpin,

impl Unpin for Nonce

impl Unpin for Sm4Ctr

impl Unpin for Counter

impl<T> Unpin for Mmap<T>where
    T: Unpin,

impl<T> Unpin for MmapMut<T>where
    T: Unpin,

impl Unpin for MapAddr

impl<T> Unpin for MapObject<T>

impl Unpin for Zero

impl Unpin for Nothing