pub enum Runtime {
Tokio1,
AsyncStd1,
}
managed
only.Expand description
Enumeration for picking a runtime implementation.
Variants
Tokio1
tokio
1.0 runtime.
AsyncStd1
async-std
1.0 runtime.
Implementations
sourceimpl Runtime
impl Runtime
sourcepub async fn timeout<F>(
&'_ self,
duration: Duration,
future: F
) -> Option<<F as Future>::Output> where
F: Future,
pub async fn timeout<F>(
&'_ self,
duration: Duration,
future: F
) -> Option<<F as Future>::Output> where
F: Future,
Requires a Future
to complete before the specified duration
has
elapsed.
If the future
completes before the duration
has elapsed, then the
completed value is returned. Otherwise, an error is returned and
the future
is canceled.
sourcepub async fn spawn_blocking<F, R>(
&'_ self,
f: F
) -> Result<R, SpawnBlockingError> where
F: 'static + FnOnce() -> R + Send,
R: 'static + Send,
pub async fn spawn_blocking<F, R>(
&'_ self,
f: F
) -> Result<R, SpawnBlockingError> where
F: 'static + FnOnce() -> R + Send,
R: 'static + Send,
Runs the given closure on a thread where blocking is acceptable.
Errors
See SpawnBlockingError
for details.
sourcepub fn spawn_blocking_background<F>(
&self,
f: F
) -> Result<(), SpawnBlockingError> where
F: 'static + FnOnce() + Send,
pub fn spawn_blocking_background<F>(
&self,
f: F
) -> Result<(), SpawnBlockingError> where
F: 'static + FnOnce() + Send,
Runs the given closure on a thread where blocking is acceptable.
It works similar to Runtime::spawn_blocking()
but doesn’t return a
Future
and is meant to be used for background tasks.
Errors
See SpawnBlockingError
for details.
Trait Implementations
impl Copy for Runtime
impl Eq for Runtime
impl StructuralEq for Runtime
impl StructuralPartialEq for Runtime
Auto Trait Implementations
impl RefUnwindSafe for Runtime
impl Send for Runtime
impl Sync for Runtime
impl Unpin for Runtime
impl UnwindSafe for Runtime
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more