pub enum TokioRT {
Runtime(Runtime),
Handle(Handle),
}Expand description
The main struct for tokio runtime IO, assign this type to AsyncIO trait when used.
Variants§
Implementations§
Source§impl TokioRT
impl TokioRT
Sourcepub fn new_with_runtime(rt: Runtime) -> Self
pub fn new_with_runtime(rt: Runtime) -> Self
Capture a runtime
pub fn new_multi_thread(workers: usize) -> Self
pub fn new_current_thread() -> Self
Sourcepub fn new_with_handle(handle: Handle) -> Self
pub fn new_with_handle(handle: Handle) -> Self
Only capture a runtime handle. Should acquire with
async { Handle::current() }
Trait Implementations§
Source§impl AsyncExec for TokioRT
impl AsyncExec for TokioRT
Source§fn spawn<F, R>(&self, f: F) -> Self::AsyncHandle<R>
fn spawn<F, R>(&self, f: F) -> Self::AsyncHandle<R>
Spawn a task in the background, returning a handle to await its result
Source§fn spawn_detach<F, R>(&self, f: F)
fn spawn_detach<F, R>(&self, f: F)
Spawn a task and detach it (no handle returned)
Source§fn block_on<F, R>(&self, f: F) -> Rwhere
F: Future<Output = R>,
R: 'static,
fn block_on<F, R>(&self, f: F) -> Rwhere
F: Future<Output = R>,
R: 'static,
Run a future to completion on the runtime
type AsyncHandle<R: Send> = TokioJoinHandle<R>
type ThreadHandle<R: Send> = TokioThreadHandle<R>
Source§fn spawn_blocking<F, R>(f: F) -> Self::ThreadHandle<R>
fn spawn_blocking<F, R>(f: F) -> Self::ThreadHandle<R>
Run blocking code in a background thread pool, and return an async join handle Read more
Source§impl AsyncIO for TokioRT
impl AsyncIO for TokioRT
Source§type AsyncFd<T: AsRawFd + AsFd + Send + Sync + 'static> = TokioFD<T>
type AsyncFd<T: AsRawFd + AsFd + Send + Sync + 'static> = TokioFD<T>
The type used to represent async file descriptors. Read more
Source§async fn connect_tcp(addr: &SocketAddr) -> Result<Self::AsyncFd<TcpStream>>
async fn connect_tcp(addr: &SocketAddr) -> Result<Self::AsyncFd<TcpStream>>
Connect to a TCP address asynchronously. Read more
Source§async fn connect_unix(addr: &Path) -> Result<Self::AsyncFd<UnixStream>>
async fn connect_unix(addr: &Path) -> Result<Self::AsyncFd<UnixStream>>
Connect to a Unix socket address asynchronously. Read more
Source§impl AsyncTime for TokioRT
impl AsyncTime for TokioRT
impl AsyncRuntime for TokioRT
Auto Trait Implementations§
impl !Freeze for TokioRT
impl RefUnwindSafe for TokioRT
impl Send for TokioRT
impl Sync for TokioRT
impl Unpin for TokioRT
impl UnwindSafe for TokioRT
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