nathansizemore / epoll Goto Github PK
View Code? Open in Web Editor NEWRust epoll wrapper
License: Mozilla Public License 2.0
Rust epoll wrapper
License: Mozilla Public License 2.0
Have you consider changing the argument order for epoll::wait
to match the order used by Linux's epoll_wait
? User familiar with Linux's epoll API would find the signature more natural if epoll::wait
had the same order.
I propose the following signature:
pub fn wait(epfd: RawFd, events: &mut [Event], timeout: i32) -> io::Result<usize>
bitflags! {
pub struct ControlOptions: i32 {
/// Indicates an addition to the interest list.
const EPOLL_CTL_ADD = libc::EPOLL_CTL_ADD;
/// Indicates a modification of flags for an interest already in list.
const EPOLL_CTL_MOD = libc::EPOLL_CTL_MOD;
/// Indicates a removal of an interest from the list.
const EPOLL_CTL_DEL = libc::EPOLL_CTL_DEL;
}
}
โ libc [master โ] $ grep EPOLL_CTL src/unix/notbsd/mod.rs
pub const EPOLL_CTL_ADD: ::c_int = 1;
pub const EPOLL_CTL_MOD: ::c_int = 3;
pub const EPOLL_CTL_DEL: ::c_int = 2;
It would be nice if the Event struct would also have the debug trait.
#[derive(Debug)]
should work, however a custom implementation which shows the Flags would be even better.
epoll depends on bitflags 1.0, but the latest 4.3.0 release depends on a function from_bits_unchecked
which is only implemented in bitflags 1.2.
This gives issues when upgrading if the project that uses epoll also uses bitflags 1.0. The fix should be to require bitflags 1.2
System: Mac m1
bruce@192 admin % cargo check
Checking epoll v4.3.3
error[E0425]: cannot find value `EPOLL_CTL_ADD` in crate `libc`
--> /Users/bruce/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/epoll-4.3.3/src/lib.rs:19:27
|
19 | EPOLL_CTL_ADD = libc::EPOLL_CTL_ADD,
| ^^^^^^^^^^^^^ not found in `libc`
|
help: consider importing this unit variant
|
11 + use ControlOptions::EPOLL_CTL_ADD;
|
help: if you import `EPOLL_CTL_ADD`, refer to it directly
|
19 - EPOLL_CTL_ADD = libc::EPOLL_CTL_ADD,
19 + EPOLL_CTL_ADD = EPOLL_CTL_ADD,
|
error[E0425]: cannot find value `EPOLL_CTL_MOD` in crate `libc`
--> /Users/bruce/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/epoll-4.3.3/src/lib.rs:21:27
|
21 | EPOLL_CTL_MOD = libc::EPOLL_CTL_MOD,
| ^^^^^^^^^^^^^ not found in `libc`
|
help: consider importing this unit variant
|
11 + use ControlOptions::EPOLL_CTL_MOD;
|
help: if you import `EPOLL_CTL_MOD`, refer to it directly
|
21 - EPOLL_CTL_MOD = libc::EPOLL_CTL_MOD,
21 + EPOLL_CTL_MOD = EPOLL_CTL_MOD,
|
error[E0425]: cannot find value `EPOLL_CTL_DEL` in crate `libc`
--> /Users/bruce/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/epoll-4.3.3/src/lib.rs:23:27
|
23 | EPOLL_CTL_DEL = libc::EPOLL_CTL_DEL,
| ^^^^^^^^^^^^^ not found in `libc`
|
help: consider importing this unit variant
|
11 + use ControlOptions::EPOLL_CTL_DEL;
|
help: if you import `EPOLL_CTL_DEL`, refer to it directly
|
23 - EPOLL_CTL_DEL = libc::EPOLL_CTL_DEL,
23 + EPOLL_CTL_DEL = EPOLL_CTL_DEL,
|
error[E0425]: cannot find value `EPOLLET` in crate `libc`
--> /Users/bruce/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/epoll-4.3.3/src/lib.rs:33:36
|
33 | const EPOLLET = libc::EPOLLET as u32;
| ^^^^^^^ not found in `libc`
error[E0425]: cannot find value `EPOLLIN` in crate `libc`
--> /Users/bruce/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/epoll-4.3.3/src/lib.rs:35:36
|
35 | const EPOLLIN = libc::EPOLLIN as u32;
| ^^^^^^^ help: a constant with a similar name exists: `POLLIN`
|
::: /Users/bruce/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/libc-0.2.147/src/unix/bsd/mod.rs:473:1
|
473 | pub const POLLIN: ::c_short = 0x1;
| --------------------------- similarly named constant `POLLIN` defined here
error[E0425]: cannot find value `EPOLLERR` in crate `libc`
--> /Users/bruce/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/epoll-4.3.3/src/lib.rs:39:36
|
39 | const EPOLLERR = libc::EPOLLERR as u32;
| ^^^^^^^^ help: a constant with a similar name exists: `POLLERR`
|
::: /Users/bruce/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/libc-0.2.147/src/unix/bsd/mod.rs:476:1
|
476 | pub const POLLERR: ::c_short = 0x8;
| ---------------------------- similarly named constant `POLLERR` defined here
error[E0425]: cannot find value `EPOLLHUP` in crate `libc`
--> /Users/bruce/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/epoll-4.3.3/src/lib.rs:47:36
|
47 | const EPOLLHUP = libc::EPOLLHUP as u32;
| ^^^^^^^^ help: a constant with a similar name exists: `POLLHUP`
|
::: /Users/bruce/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/libc-0.2.147/src/unix/bsd/mod.rs:477:1
|
477 | pub const POLLHUP: ::c_short = 0x10;
| ---------------------------- similarly named constant `POLLHUP` defined here
error[E0425]: cannot find value `EPOLLOUT` in crate `libc`
--> /Users/bruce/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/epoll-4.3.3/src/lib.rs:49:36
|
49 | const EPOLLOUT = libc::EPOLLOUT as u32;
| ^^^^^^^^ help: a constant with a similar name exists: `POLLOUT`
|
::: /Users/bruce/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/libc-0.2.147/src/unix/bsd/mod.rs:475:1
|
475 | pub const POLLOUT: ::c_short = 0x4;
| ---------------------------- similarly named constant `POLLOUT` defined here
error[E0425]: cannot find value `EPOLLPRI` in crate `libc`
--> /Users/bruce/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/epoll-4.3.3/src/lib.rs:51:36
|
51 | const EPOLLPRI = libc::EPOLLPRI as u32;
| ^^^^^^^^ help: a constant with a similar name exists: `POLLPRI`
|
::: /Users/bruce/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/libc-0.2.147/src/unix/bsd/mod.rs:474:1
|
474 | pub const POLLPRI: ::c_short = 0x2;
| ---------------------------- similarly named constant `POLLPRI` defined here
error[E0425]: cannot find value `EPOLLRDHUP` in crate `libc`
--> /Users/bruce/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/epoll-4.3.3/src/lib.rs:56:36
|
56 | const EPOLLRDHUP = libc::EPOLLRDHUP as u32;
| ^^^^^^^^^^ help: a constant with a similar name exists: `POLLHUP`
|
::: /Users/bruce/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/libc-0.2.147/src/unix/bsd/mod.rs:477:1
|
477 | pub const POLLHUP: ::c_short = 0x10;
| ---------------------------- similarly named constant `POLLHUP` defined here
error[E0425]: cannot find value `EPOLLWAKEUP` in crate `libc`
--> /Users/bruce/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/epoll-4.3.3/src/lib.rs:66:36
|
66 | const EPOLLWAKEUP = libc::EPOLLWAKEUP as u32;
| ^^^^^^^^^^^ not found in `libc`
error[E0425]: cannot find value `EPOLLONESHOT` in crate `libc`
--> /Users/bruce/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/epoll-4.3.3/src/lib.rs:73:36
|
73 | const EPOLLONESHOT = libc::EPOLLONESHOT as u32;
| ^^^^^^^^^^^^ help: a constant with a similar name exists: `EV_ONESHOT`
|
::: /Users/bruce/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/libc-0.2.147/src/unix/bsd/apple/mod.rs:4080:1
|
4080 | pub const EV_ONESHOT: u16 = 0x10;
| ------------------------- similarly named constant `EV_ONESHOT` defined here
error[E0425]: cannot find value `EPOLLEXCLUSIVE` in crate `libc`
--> /Users/bruce/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/epoll-4.3.3/src/lib.rs:102:38
|
102 | ...= libc::EPOLLEXCLUSIVE as u32;
| ^^^^^^^^^^^^^^ not found in `libc`
error[E0425]: cannot find value `EPOLL_CLOEXEC` in crate `libc`
--> /Users/bruce/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/epoll-4.3.3/src/lib.rs:142:36
|
142 | ...loexec { libc::EPOLL_CLOEXEC } else { 0 };
| ^^^^^^^^^^^^^ help: a constant with a similar name exists: `O_CLOEXEC`
|
::: /Users/bruce/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/libc-0.2.147/src/unix/bsd/apple/mod.rs:2884:1
|
2884 | pub const O_CLOEXEC: ::c_int = 0x01000000;
| ---------------------------- similarly named constant `O_CLOEXEC` defined here
error[E0425]: cannot find function `epoll_create1` in crate `libc`
--> /Users/bruce/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/epoll-4.3.3/src/lib.rs:143:24
|
143 | unsafe { cvt(libc::epoll_create1(flags)) }
| ^^^^^^^^^^^^^ not found in `libc`
error[E0412]: cannot find type `epoll_event` in crate `libc`
--> /Users/bruce/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/epoll-4.3.3/src/lib.rs:153:48
|
153 | ...ut libc::epoll_event;
| ^^^^^^^^^^^ not found in `libc`
error[E0425]: cannot find function `epoll_ctl` in crate `libc`
--> /Users/bruce/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/epoll-4.3.3/src/lib.rs:154:24
|
154 | ...cvt(libc::epoll_ctl(epfd, op as i32, fd, e))? };
| ^^^^^^^^^ not found in `libc`
error[E0425]: cannot find function `epoll_wait` in crate `libc`
--> /Users/bruce/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/epoll-4.3.3/src/lib.rs:166:19
|
166 | cvt(libc::epoll_wait(
| ^^^^^^^^^^ not found in `libc`
error[E0412]: cannot find type `epoll_event` in crate `libc`
--> /Users/bruce/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/epoll-4.3.3/src/lib.rs:168:44
|
168 | buf.as_mut_ptr() as *mut libc::epoll_event,
| ^^^^^^^^^^^ not found in `libc`
Some errors have detailed explanations: E0412, E0425.
For more information about an error, try `rustc --explain E0412`.
error: could not compile `epoll` (lib) due to 19 previous errors
Are you aware of nix::sys::epoll
, repository here?
epoll
?Either way, there's no reason that we shouldn't have both, and let the best man win... If there's a useful comparison to be made, maybe put something in the README?
(Hope this doesn't sound hostile - raising an issue feels like a slightly aggressive way of asking a question - I'm just curious.)
Implementing std::error::Error trait for CreateError, CtlError and WaitError will simplify error handling.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.