Skip to main content

TokioRT

Struct TokioRT 

Source
pub struct TokioRT {}

Trait Implementations§

Source§

impl AsyncIO for TokioRT

Source§

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>>

Connect to a TCP address asynchronously. Read more
Source§

async fn connect_unix(addr: &Path) -> Result<Self::AsyncFd<UnixStream>>

Connect to a Unix socket address asynchronously. Read more
Source§

fn to_async_fd_rd<T: AsRawFd + AsFd + Send + Sync + 'static>( fd: T, ) -> Result<Self::AsyncFd<T>>

Wrap a readable file object as an async handle Read more
Source§

fn to_async_fd_rw<T: AsRawFd + AsFd + Send + Sync + 'static>( fd: T, ) -> Result<Self::AsyncFd<T>>

Wrap a readable/writable file object as an async handle. Read more
Source§

impl AsyncRuntime for TokioRT

Source§

fn current() -> Self::Exec

Initiate executor using current thread.

§Safety

You should run AsyncExec::block_on() with this executor.

If spawn without a block_on() running, it’s possible the runtime just init future without scheduling.

Source§

fn one() -> Self::Exec

Initiate executor with one background thread.

§NOTE

AsyncExec::block_on() is optional, you can directly call AsyncExec::spawn with it.

Source§

fn multi(num: usize) -> Self::Exec

Initiate executor with multiple background threads.

§NOTE

When num == 0, start threads that match cpu number.

AsyncExec::block_on() is optional, you can directly call AsyncExec::spawn with it.

Source§

fn spawn<F, R>(f: F) -> TokioJoinHandle<R>
where F: Future<Output = R> + Send + 'static, R: Send + 'static,

Spawn a task in the background, returning a handle to await its result

Source§

fn spawn_detach<F, R>(f: F)
where F: Future<Output = R> + Send + 'static, R: Send + 'static,

Spawn a task and detach it (no handle returned)

Source§

type Exec = TokioExec

Source§

fn spawn_blocking<F, R>(f: F) -> TokioThreadHandle<R>
where F: FnOnce() -> R + Send + 'static, R: Send + 'static,

Run blocking code with the thread context in blocking thread pool, and return an async join handle Read more
Source§

impl AsyncTime for TokioRT

Source§

type Interval = TokioInterval

The type used for periodic timers.
Source§

fn sleep(d: Duration) -> impl Future + Send

Sleep for the specified duration. Read more
Source§

fn interval(d: Duration) -> Self::Interval

Create a periodic timer that ticks at the specified interval. Read more
Source§

fn timeout<F>( d: Duration, func: F, ) -> impl Future<Output = Result<<F as Future>::Output, ()>> + Send
where F: Future + Send,

Apply a timeout to a future. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.