Struct safina_sync::Promise[][src]

pub struct Promise<T: Send + 'static> { /* fields omitted */ }

A Future that resolves when you call set on its clone.

Uses Arc internally. All clones of this struct use the same inner struct on the heap.

You can call set on any clone of this struct.

You can call set once and await once, obtaining the value.

Subsequent or concurrent awaits of the struct will wait forever.

Implementations

impl<T: Send + 'static> Promise<T>[src]

#[must_use]pub fn new() -> Self[src]

#[must_use]pub fn is_set(&self) -> bool[src]

Returns true if set has been called.

Panics

Panics if the inner mutex is poisoned.

pub fn set(self, value: T)[src]

Sets the value of the struct and wakes up any awaiting task.

Consumes the struct.

Panics

Panics if the value was already set.

pub fn try_set(&self, value: T) -> Result<(), T>[src]

Sets the value of the struct and wakes up any awaiting task.

Errors

Returns Err(value) if the value was already set. This returns the value just passed in.

Trait Implementations

impl<T: Send + 'static> Clone for Promise<T>[src]

impl<T: Send + 'static> Default for Promise<T>[src]

impl<T: Send + 'static> Future for Promise<T>[src]

type Output = T

The type of value produced on completion.

Auto Trait Implementations

impl<T> RefUnwindSafe for Promise<T>

impl<T> Send for Promise<T>

impl<T> Sync for Promise<T>

impl<T> Unpin for Promise<T>

impl<T> UnwindSafe for Promise<T>

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<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> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.