Struct safina_sync::Promise [−][src]
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]
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]
fn clone(&self) -> Self
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<T: Send + 'static> Default for Promise<T>
[src]
impl<T: Send + 'static> Future for Promise<T>
[src]
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<F> IntoFuture for F where
F: Future,
[src]
F: Future,
type Output = <F as Future>::Output
into_future
)The output that the future will produce on completion.
type Future = F
into_future
)Which kind of future are we turning this into?
pub fn into_future(self) -> <F as IntoFuture>::Future
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,