pub enum TrySync<F: Future> {
Sync(F::Output),
Async(F),
SyncPolled,
}Expand description
An async wrapper with an optimized synchronous execution path.
It is used in combination with Future trait objects, such as
DynObject<dyn Future<Output=T>>.
§Examples
trait Callback {
fn call(&self, arg: &str) -> TrySync<DynObject<dyn Future<Output = ()>>>;
}
struct Print;
impl Callback for Print {
fn call(&self, arg: &str) -> TrySync<DynObject<dyn Future<Output = ()>>> {
println!("{arg}");
TrySync::Sync(())
}
}Variants§
Sync(F::Output)
Optimized synchronous execution path.
Async(F)
Asynchronous wrapper
SyncPolled
Synchronous execution path already polled
Trait Implementations§
Auto Trait Implementations§
impl<F> Freeze for TrySync<F>
impl<F> RefUnwindSafe for TrySync<F>
impl<F> Send for TrySync<F>
impl<F> Sync for TrySync<F>
impl<F> Unpin for TrySync<F>
impl<F> UnwindSafe for TrySync<F>
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
Source§impl<F> IntoFuture for Fwhere
F: Future,
impl<F> IntoFuture for Fwhere
F: Future,
Source§type IntoFuture = F
type IntoFuture = F
Which kind of future are we turning this into?
Source§fn into_future(self) -> <F as IntoFuture>::IntoFuture
fn into_future(self) -> <F as IntoFuture>::IntoFuture
Creates a future from a value. Read more