[][src]Struct assert_unmoved::AssertUnmoved

pub struct AssertUnmoved<T> { /* fields omitted */ }

A type that asserts that the underlying type is not moved after being pinned and mutably accessed.

See crate level documentation for details.

Implementations

impl<T> AssertUnmoved<T>[src]

pub const fn new(inner: T) -> Self[src]

Creates a new AssertUnmoved.

pub const fn get_ref(&self) -> &T[src]

Gets a reference to the underlying type.

Unlike get_mut method, this method can always called.

You can also access the underlying type via Deref impl.

pub fn get_mut(&mut self) -> &mut T[src]

Gets a mutable reference to the underlying type.

Note that this method can only be called before pinned since AssertUnmoved is !Unpin.

pub fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut T>[src]

Gets a pinned mutable reference to the underlying type.

Examples

Implement own Stream trait for AssertUnmoved.

use assert_unmoved::AssertUnmoved;
use std::{
    pin::Pin,
    task::{Context, Poll},
};

pub trait MyStream {
    type Item;

    fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>>;
}

impl<S: MyStream> MyStream for AssertUnmoved<S> {
    type Item = S::Item;

    fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
        self.get_pin_mut().poll_next(cx)
    }
}

Trait Implementations

impl<R: AsyncBufRead> AsyncBufRead for AssertUnmoved<R>[src]

impl<R: AsyncBufRead> AsyncBufRead for AssertUnmoved<R>[src]

impl<R: AsyncBufRead> AsyncBufRead for AssertUnmoved<R>[src]

impl<R: AsyncRead> AsyncRead for AssertUnmoved<R>[src]

impl<R: AsyncRead> AsyncRead for AssertUnmoved<R>[src]

impl<R: AsyncRead> AsyncRead for AssertUnmoved<R>[src]

impl<S: AsyncSeek> AsyncSeek for AssertUnmoved<S>[src]

impl<S: AsyncSeek> AsyncSeek for AssertUnmoved<S>[src]

impl<S: AsyncSeek> AsyncSeek for AssertUnmoved<S>[src]

impl<W: AsyncWrite> AsyncWrite for AssertUnmoved<W>[src]

impl<W: AsyncWrite> AsyncWrite for AssertUnmoved<W>[src]

impl<W: AsyncWrite> AsyncWrite for AssertUnmoved<W>[src]

impl<T: Debug> Debug for AssertUnmoved<T>[src]

impl<T: Default> Default for AssertUnmoved<T>[src]

fn default() -> Self[src]

Creates a new AssertUnmoved, with the default value for T.

This is equivalent to AssertUnmoved::new(T::default()).

impl<T> Deref for AssertUnmoved<T>[src]

type Target = T

The resulting type after dereferencing.

impl<T> Drop for AssertUnmoved<T>[src]

impl<T> From<T> for AssertUnmoved<T>[src]

fn from(inner: T) -> Self[src]

Converts a T into a AssertUnmoved<T>.

This is equivalent to AssertUnmoved::new.

impl<F: FusedFuture> FusedFuture for AssertUnmoved<F>[src]

impl<S: FusedStream> FusedStream for AssertUnmoved<S>[src]

impl<F: Future> Future for AssertUnmoved<F>[src]

type Output = F::Output

The type of value produced on completion.

impl<T> PinnedDrop for AssertUnmoved<T>[src]

impl<T: Send> Send for AssertUnmoved<T>[src]

impl<S: Sink<Item>, Item> Sink<Item> for AssertUnmoved<S>[src]

type Error = S::Error

The type of value produced by the sink when an error occurs.

impl<S: Stream> Stream for AssertUnmoved<S>[src]

type Item = S::Item

Values yielded by the stream.

impl<T: Sync> Sync for AssertUnmoved<T>[src]

impl<'pin, T> Unpin for AssertUnmoved<T> where
    Wrapper<'pin, PhantomPinned>: Unpin
[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for AssertUnmoved<T> where
    T: RefUnwindSafe

impl<T> UnwindSafe for AssertUnmoved<T> where
    T: RefUnwindSafe + UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<R> AsyncBufReadExt for R where
    R: AsyncBufRead + ?Sized
[src]

impl<R> AsyncReadExt for R where
    R: AsyncRead + ?Sized
[src]

impl<S> AsyncSeekExt for S where
    S: AsyncSeek + ?Sized
[src]

impl<W> AsyncWriteExt for W where
    W: AsyncWrite + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<!> for T[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<F> IntoFuture for F where
    F: Future
[src]

type Output = <F as Future>::Output

🔬 This is a nightly-only experimental API. (into_future)

The output that the future will produce on completion.

type Future = F

🔬 This is a nightly-only experimental API. (into_future)

Which kind of future are we turning this into?

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<F, T, E> TryFuture for F where
    F: Future<Output = Result<T, E>> + ?Sized
[src]

type Ok = T

The type of successful values yielded by this future

type Error = E

The type of failures yielded by this future

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<S, T, E> TryStream for S where
    S: Stream<Item = Result<T, E>> + ?Sized
[src]

type Ok = T

The type of successful values yielded by this future

type Error = E

The type of failures yielded by this future