Skip to main content

RuntimeInterface

Trait RuntimeInterface 

Source
pub trait RuntimeInterface: Sized {
Show 27 associated items type JoinHandle<T: Send + 'static>: Future<Output = T> + Send + 'static; type MpscSender<T: Send + 'static>: MpscSender<T> + 'static; type MpscReceiver<T: Send + 'static>: MpscReceiver<T> + 'static; type OneshotSender<T: Send + 'static>: OneshotSender<T> + 'static; type OneshotReceiver<T: Send + 'static>: Future<Output = Result<T, OneshotRecvError>> + Send + 'static; type BroadcastSender<T: Send + Clone + 'static>: BroadcastSender<T> + 'static; type BroadcastReceiver<T: Send + Clone + 'static>: BroadcastReceiver<T> + 'static; type WatchSender<T: Send + Sync + 'static>: WatchSender<T> + 'static; type WatchReceiver<T: Send + Sync + Clone + 'static>: WatchReceiver<T> + 'static; type File: AsyncFile + 'static; type TcpListener: TcpListener<Stream = Self::TcpStream> + 'static; type TcpStream: TcpStream + 'static; type UdpSocket: UdpSocket + 'static; // Required methods fn spawn<F>(&self, future: F) -> Self::JoinHandle<F::Output> where F: Future + Send + 'static, F::Output: Send + 'static; fn block_on<F: Future>(&self, future: F) -> F::Output; fn sleep( &self, duration: Duration, ) -> Pin<Box<dyn Future<Output = ()> + Send + '_>>; fn timeout<'a, F: Future + Send + 'a>( &'a self, duration: Duration, future: F, ) -> Pin<Box<dyn Future<Output = Result<F::Output, TimeoutError>> + Send + 'a>> where F::Output: Send; fn mpsc_channel<T: Send + 'static>( &self, capacity: usize, ) -> (Self::MpscSender<T>, Self::MpscReceiver<T>); fn oneshot_channel<T: Send + 'static>( &self, ) -> (Self::OneshotSender<T>, Self::OneshotReceiver<T>); fn broadcast_channel<T: Send + Clone + 'static>( &self, capacity: usize, ) -> (Self::BroadcastSender<T>, Self::BroadcastReceiver<T>); fn watch_channel<T: Send + Sync + Clone + 'static>( &self, initial: T, ) -> (Self::WatchSender<T>, Self::WatchReceiver<T>); fn file_create<'a>( &'a self, path: &'a Path, ) -> Pin<Box<dyn Future<Output = Result<Self::File>> + Send + 'a>>; fn file_open<'a>( &'a self, path: &'a Path, ) -> Pin<Box<dyn Future<Output = Result<Self::File>> + Send + 'a>>; fn tcp_listen<'a>( &'a self, addr: &'a str, ) -> Pin<Box<dyn Future<Output = Result<Self::TcpListener>> + Send + 'a>>; fn tcp_connect<'a>( &'a self, addr: SocketAddr, ) -> Pin<Box<dyn Future<Output = Result<Self::TcpStream>> + Send + 'a>>; fn udp_bind<'a>( &'a self, addr: &'a str, ) -> Pin<Box<dyn Future<Output = Result<Self::UdpSocket>> + Send + 'a>>; // Provided method fn bench_alloc_snapshot(&self) -> Option<BenchAllocSnapshot> { ... }
}
Expand description

Trait that async runtimes must implement to run conformance tests.

This trait provides the common primitives that tests require. Each method returns a concrete type that the runtime provides.

Required Associated Types§

Source

type JoinHandle<T: Send + 'static>: Future<Output = T> + Send + 'static

Join handle for spawned tasks.

Source

type MpscSender<T: Send + 'static>: MpscSender<T> + 'static

MPSC sender.

Source

type MpscReceiver<T: Send + 'static>: MpscReceiver<T> + 'static

MPSC receiver.

Source

type OneshotSender<T: Send + 'static>: OneshotSender<T> + 'static

Oneshot sender.

Source

type OneshotReceiver<T: Send + 'static>: Future<Output = Result<T, OneshotRecvError>> + Send + 'static

Oneshot receiver.

Source

type BroadcastSender<T: Send + Clone + 'static>: BroadcastSender<T> + 'static

Broadcast sender.

Source

type BroadcastReceiver<T: Send + Clone + 'static>: BroadcastReceiver<T> + 'static

Broadcast receiver.

Source

type WatchSender<T: Send + Sync + 'static>: WatchSender<T> + 'static

Watch sender.

Source

type WatchReceiver<T: Send + Sync + Clone + 'static>: WatchReceiver<T> + 'static

Watch receiver.

Source

type File: AsyncFile + 'static

Async file handle.

Source

type TcpListener: TcpListener<Stream = Self::TcpStream> + 'static

TCP listener.

Source

type TcpStream: TcpStream + 'static

TCP stream.

Source

type UdpSocket: UdpSocket + 'static

UDP socket.

Required Methods§

Source

fn spawn<F>(&self, future: F) -> Self::JoinHandle<F::Output>
where F: Future + Send + 'static, F::Output: Send + 'static,

Spawn an async task.

Source

fn block_on<F: Future>(&self, future: F) -> F::Output

Block on a future until it completes.

Source

fn sleep( &self, duration: Duration, ) -> Pin<Box<dyn Future<Output = ()> + Send + '_>>

Sleep for a duration.

Source

fn timeout<'a, F: Future + Send + 'a>( &'a self, duration: Duration, future: F, ) -> Pin<Box<dyn Future<Output = Result<F::Output, TimeoutError>> + Send + 'a>>
where F::Output: Send,

Run a future with a timeout.

Source

fn mpsc_channel<T: Send + 'static>( &self, capacity: usize, ) -> (Self::MpscSender<T>, Self::MpscReceiver<T>)

Create an MPSC channel with the given capacity.

Source

fn oneshot_channel<T: Send + 'static>( &self, ) -> (Self::OneshotSender<T>, Self::OneshotReceiver<T>)

Create a oneshot channel.

Source

fn broadcast_channel<T: Send + Clone + 'static>( &self, capacity: usize, ) -> (Self::BroadcastSender<T>, Self::BroadcastReceiver<T>)

Create a broadcast channel.

Source

fn watch_channel<T: Send + Sync + Clone + 'static>( &self, initial: T, ) -> (Self::WatchSender<T>, Self::WatchReceiver<T>)

Create a watch channel.

Source

fn file_create<'a>( &'a self, path: &'a Path, ) -> Pin<Box<dyn Future<Output = Result<Self::File>> + Send + 'a>>

Create a file for writing.

Source

fn file_open<'a>( &'a self, path: &'a Path, ) -> Pin<Box<dyn Future<Output = Result<Self::File>> + Send + 'a>>

Open a file for reading.

Source

fn tcp_listen<'a>( &'a self, addr: &'a str, ) -> Pin<Box<dyn Future<Output = Result<Self::TcpListener>> + Send + 'a>>

Bind a TCP listener to an address.

Source

fn tcp_connect<'a>( &'a self, addr: SocketAddr, ) -> Pin<Box<dyn Future<Output = Result<Self::TcpStream>> + Send + 'a>>

Connect to a TCP address.

Source

fn udp_bind<'a>( &'a self, addr: &'a str, ) -> Pin<Box<dyn Future<Output = Result<Self::UdpSocket>> + Send + 'a>>

Bind a UDP socket to an address.

Provided Methods§

Source

fn bench_alloc_snapshot(&self) -> Option<BenchAllocSnapshot>

Snapshot allocation counters for benchmarking (if supported).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§