[−][src]Enum hreq::AsyncRuntime
Switches between different async runtimes.
This is a global singleton.
hreq supports async-std and tokio. Tokio support is enabled by default and comes in some different flavors.
AsyncStd
. Requires the featureasync-std
. Supports.block()
.TokioDefault
. The default option. A minimal tokiort-core
which executes calls in one single thread. It does nothing until the current thread blocks on a future using.block()
.TokioShared
. Picks up on a globally shared runtime by using aHandle
. This runtime cannot use the.block()
extension trait since that requires having a direct connection to the tokioRuntime
.TokioOwned
. Uses a preconfigured tokioRuntime
that is "handed over" to hreq.
Example using AsyncStd
:
use hreq::AsyncRuntime; #[cfg(feature = "async-std")] AsyncRuntime::AsyncStd.make_default();
Example using a shared tokio.
use hreq::AsyncRuntime; // assuming the current thread has some tokio runtime, such // as using the `#[tokio::main]` macro on `fn main() { .. }` AsyncRuntime::TokioShared.make_default();
Example using an owned tokio.
use hreq::AsyncRuntime; // normally: use tokio::runtime::Builder; use tokio_lib::runtime::Builder; let runtime = Builder::new() .enable_io() .enable_time() .build() .expect("Failed to build tokio runtime"); AsyncRuntime::TokioOwned(runtime).make_default();
Variants
TokioOwned(TokioRuntime)
Implementations
impl AsyncRuntime
[src]
pub fn make_default(self)
[src]
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for AsyncRuntime
impl Send for AsyncRuntime
impl Sync for AsyncRuntime
impl Unpin for AsyncRuntime
impl !UnwindSafe for AsyncRuntime
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,
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<T> Sealed<T> for T where
T: ?Sized,
T: ?Sized,
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.
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>,