pub struct Promise<T> { /* private fields */ }
Expand description
The sending side of a promise which can be used to complete a future. If 2 promises are of the same type, they can be merged and then all the futures will be resolved with clones of the result.
Implementations§
Source§impl<T> Promise<T>
impl<T> Promise<T>
Sourcepub fn new() -> (Promise<T>, PromiseFuture<T>)
pub fn new() -> (Promise<T>, PromiseFuture<T>)
Create the sending and receiving parts of the promise.
Sourcepub fn fulfill_unmergable(self, result: T)
pub fn fulfill_unmergable(self, result: T)
Fulfill the promise, the future will be woken and can retrieve the result, if used on a merged Promise the merged futures will receive PromiseDropped. So prefer Promise::fulfill on mergable results.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Promise<T>
impl<T> !RefUnwindSafe for Promise<T>
impl<T> Send for Promise<T>where
T: Send,
impl<T> Sync for Promise<T>where
T: Send,
impl<T> Unpin for Promise<T>
impl<T> !UnwindSafe for Promise<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more