pub struct Runtime<RK: RuntimeKit> { /* private fields */ }Expand description
A full-featured async runtime that combines an executor and a reactor.
Runtime<RK> wraps any RuntimeKit and adds higher-level helpers such as
domain-name resolution (Runtime::to_socket_addrs) and runtime-shutdown
error detection (Runtime::is_runtime_shutdown_error).
Concrete type aliases — NoopRuntime, SmolRuntime, TokioRuntime — are
provided for each built-in backend and are the usual entry points.
Implementations§
Source§impl<RK: RuntimeKit> Runtime<RK>
impl<RK: RuntimeKit> Runtime<RK>
Sourcepub fn to_socket_addrs<A: ToSocketAddrs + Send + 'static>(
&self,
addrs: A,
) -> SocketAddrsResolver<'_, RK, A>
pub fn to_socket_addrs<A: ToSocketAddrs + Send + 'static>( &self, addrs: A, ) -> SocketAddrsResolver<'_, RK, A>
Asynchronously resolve the given domain name
Sourcepub fn is_runtime_shutdown_error(&self, err: &Error) -> bool
pub fn is_runtime_shutdown_error(&self, err: &Error) -> bool
Check if an std::io::Error is a runtime shutdown error
Only tokio’s shutdown error is recognised, and it is recognised by its value alone: no
runtime is consulted, so the answer does not depend on which kit backs this Runtime nor
on where the error came from. What this does not do is ask the kit about its own
shutdown errors, so a SmolRuntime gets false for anything smol-specific.
Source§impl Runtime<RuntimeParts<AsyncGlobalExecutor, AsyncIO>>
impl Runtime<RuntimeParts<AsyncGlobalExecutor, AsyncIO>>
Sourcepub fn async_global_executor() -> Self
pub fn async_global_executor() -> Self
Create a new AGERuntime
Source§impl Runtime<Tokio>
impl Runtime<Tokio>
Sourcepub fn tokio() -> Result<Self>
pub fn tokio() -> Result<Self>
Create a new TokioRuntime backed by a freshly created tokio multi-threaded runtime.
Sourcepub fn tokio_current() -> Self
pub fn tokio_current() -> Self
Create a new TokioRuntime and bind it to the current tokio runtime by default.
Sourcepub fn tokio_with_handle(handle: Handle) -> Self
pub fn tokio_with_handle(handle: Handle) -> Self
Create a new TokioRuntime and bind it to the tokio runtime associated to this handle by default.
Sourcepub fn tokio_with_runtime(runtime: TokioRT) -> Self
pub fn tokio_with_runtime(runtime: TokioRT) -> Self
Create a new TokioRuntime and bind it to this tokio runtime.
Trait Implementations§
Source§impl<RK: RuntimeKit> Executor for Runtime<RK>
impl<RK: RuntimeKit> Executor for Runtime<RK>
Source§type Task<T: Send + 'static> = <RK as Executor>::Task<T>
type Task<T: Send + 'static> = <RK as Executor>::Task<T>
Source§impl<RK: RuntimeKit> From<RK> for Runtime<RK>
impl<RK: RuntimeKit> From<RK> for Runtime<RK>
Source§impl<RK: RuntimeKit> Reactor for Runtime<RK>
impl<RK: RuntimeKit> Reactor for Runtime<RK>
Source§type TcpStream = <RK as Reactor>::TcpStream
type TcpStream = <RK as Reactor>::TcpStream
Source§type Sleep = <RK as Reactor>::Sleep
type Sleep = <RK as Reactor>::Sleep
Reactor::sleep)Source§fn register<H: Read + Write + AsSysFd + Send + 'static>(
&self,
socket: H,
) -> Result<impl AsyncRead + AsyncWrite + Send + Unpin + 'static>
fn register<H: Read + Write + AsSysFd + Send + 'static>( &self, socket: H, ) -> Result<impl AsyncRead + AsyncWrite + Send + Unpin + 'static>
Source§fn interval(
&self,
dur: Duration,
) -> impl Stream<Item = Instant> + Send + 'static
fn interval( &self, dur: Duration, ) -> impl Stream<Item = Instant> + Send + 'static
Source§fn tcp_connect_addr(
&self,
addr: SocketAddr,
) -> impl Future<Output = Result<Self::TcpStream>> + Send + 'static
fn tcp_connect_addr( &self, addr: SocketAddr, ) -> impl Future<Output = Result<Self::TcpStream>> + Send + 'static
Auto Trait Implementations§
impl<RK> Freeze for Runtime<RK>where
RK: Freeze,
impl<RK> RefUnwindSafe for Runtime<RK>where
RK: RefUnwindSafe,
impl<RK> Send for Runtime<RK>where
RK: Send,
impl<RK> Sync for Runtime<RK>where
RK: Sync,
impl<RK> Unpin for Runtime<RK>where
RK: Unpin,
impl<RK> UnsafeUnpin for Runtime<RK>where
RK: UnsafeUnpin,
impl<RK> UnwindSafe for Runtime<RK>where
RK: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more