Enum hreq::AsyncRuntime [−][src]
Switches between different async runtimes.
This is a global singleton.
hreq supports different ways of using tokio.
TokioSingle
. 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.
Variants
Use a tokio rt-core
single threaded runtime. This is the default.
Pick up on a tokio shared runtime.
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();
TokioOwned(TokioRuntime)
Use a tokio runtime owned by hreq.
Example using an owned tokio.
use hreq::AsyncRuntime; // normally: use tokio::runtime::Builder; use tokio::runtime::Builder; let runtime = Builder::new_multi_thread() .enable_io() .enable_time() .build() .expect("Failed to build tokio runtime"); AsyncRuntime::TokioOwned(runtime).make_default();
Implementations
impl AsyncRuntime
[src]
pub fn make_default(self)
[src]
Make this runtime the default.
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,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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>,