Crates.io | popol |
lib.rs | popol |
version | 3.0.0 |
source | src |
created_at | 2020-07-05 21:47:47.304949 |
updated_at | 2023-05-16 11:30:01.355389 |
description | Minimal non-blocking I/O |
homepage | https://github.com/cloudhead/popol |
repository | https://github.com/cloudhead/popol |
max_upload_size | |
id | 261734 |
size | 42,993 |
Minimal non-blocking I/O for Rust.
See examples/
folder for usage.
Async I/O in Rust is still an unsolved problem. With the stabilization of
async/await, we are seeing a number of libraries and runtimes crop up, such
as async-std and smol, while others such as tokio and mio are maturing.
The problem with async/await is that you can't use any of the standard
library traits, such as Read
and Write
. The async ecosystem comes with an
entirely separate suite of traits (eg. AsyncRead
and AsyncWrite
) and I/O
libraries. Furthermore, most of these runtimes have a large dependency
footprint, partly from having to provide async alternatives to the standard
library functions, and partly due to the complexity of these runtimes.
What do we need? For most use-cases, the ability to handle between a dozen
and up to a few hundred open connections without blocking, is all we need.
This places us squarely within the territory of the venerable poll()
function,
which is available on almost all platforms.
Popol is designed as a minimal ergonomic wrapper around poll()
, built for
peer-to-peer networking.
By building on poll
, we have the following advantages:
io::Read
, io::Write
, etc.)Why not use epoll
? A couple of reasons:
poll
and requires us to write more codepoll
is sufficient for handling most workloadsCompared to mio, popol is:
Some of the advantages of popol's API over mio's:
u64
.On the other hand, mio is more mature and probably better at handling very large number of connections. Mio also currently supports more platforms.
This software is licensed under the MIT license. See the LICENSE
file for
details.
(c) Alexis Sellier https://cloudhead.io