The tokio crate

The tokio crate provides the functionality to work with the network connections of files in an asynchronous manner. It includes wrappers for the TCP and UDP sockets—TcpStream and UdpSocket. It also includes types to access a filesystem through the Future and Stream traits. There is no cross-platform approach to work with files asynchronously, because operating systems have their own implementations of non-blocking APIs. Some operating systems, however, don't have good asynchronous APIs at all. To provide cross-platform asynchronous access to filesystems, tokio uses the tokio_threadpool crate, which has a blocking method that runs a task in a separate thread. This helps to implement asynchronous interaction for types that can block the thread using input/output operations. It isn't the most effective way to interact with a filesystem, but it does allow us to convert synchronous APIs to asynchronous. The tokio crate also contains an Executor trait and a Timer module. We've considered executors before. The timer module contains the Timeout and Interval types to create a Future and a Stream that generate values whenever a specified time period has elapsed.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.143.0.85