[][src]Struct mrwei::Promise

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

A struct that accepts a value and notify the corresponding future.

Implementations

impl<T> Promise<T>[src]

pub fn set_value(self, value: T) -> Option<T>[src]

Offers a value to the promise.

It will wake up any awaited futures.

pub fn into_raw(s: Promise<T>) -> NonNull<MaybeUninit<T>>[src]

Get a mutable pointer to the underlying value.

Remember to use from_raw to reclaim the memory and make notification work correctly.

pub unsafe fn from_raw(ptr: NonNull<MaybeUninit<T>>) -> Promise<T>[src]

Reconstruct the promise from given pointer.

The pointer must be the returned value of into_raw.

Safety

If the pointer is not generated by into_raw, it can lead to undefined behavior.

pub unsafe fn assume_value_set(self)[src]

Assumes the value is set.

It will wake up any awaited futures.

Safety

If no value has been set, calling the function lead to undefined behavior.

Trait Implementations

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

pub fn drop(&mut self)[src]

Drops the promise.

It will wake up any awaited futures.

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

Auto Trait Implementations

impl<T> !RefUnwindSafe for Promise<T>[src]

impl<T> !Sync for Promise<T>[src]

impl<T> Unpin for Promise<T>[src]

impl<T> !UnwindSafe for Promise<T>[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?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<T> for T[src]

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

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<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.