10 stable releases

✓ Uses Rust 2018 edition

new 2.0.2 May 23, 2020
2.0.1 May 10, 2020
2.0.0 Apr 26, 2020
1.1.0 Feb 10, 2020
1.0.4 Apr 6, 2019

#12 in Windows APIs

Download history 5/week @ 2020-01-25 4/week @ 2020-02-01 28/week @ 2020-02-08 8/week @ 2020-02-15 116/week @ 2020-02-22 15/week @ 2020-03-07 9/week @ 2020-03-14 22/week @ 2020-03-21 36/week @ 2020-03-28 48/week @ 2020-04-04 53/week @ 2020-04-11 30/week @ 2020-04-18 1116/week @ 2020-04-25 1031/week @ 2020-05-02 1344/week @ 2020-05-09

1,969 downloads per month
Used in 67 crates (via smol)

MPL-2.0 license

17KB
327 lines

wepoll-binding

Safe Rust bindings for wepoll, using wepoll-sys.

Requirements

  • Rust 2018
  • Windows
  • clang
  • A compiler such as gcc, the MSVC compiler (cl.exe), etc

Usage

Add wepoll-binding as a Windows dependency (since it won't build on other platforms):

[dependencies.'cfg(windows)'.dependencies]
wepoll-binding = "^2.0"

Next you'll need to create an Epoll instance, and register some sockets with it:

use wepoll_binding::{Epoll, EventFlag};
use std::net::UdpSocket;

let epoll = Epoll::new().unwrap();
let socket = UdpSocket::new("0.0.0.0:0").unwrap();

epoll.register(&socket, EventFlag::OUT | EventFlag::ONESHOT, 42).unwrap();

You can poll for events using Epoll::poll(). For this you'll need to create an Events buffer:

use wepoll_binding::{Epoll, EventFlag, Events};
use std::net::UdpSocket;

let epoll = Epoll::new().unwrap();
let socket = UdpSocket::new("0.0.0.0:0").unwrap();
let mut events = Events::with_capacity(1);

epoll.register(&socket, EventFlag::OUT | EventFlag::ONESHOT, 42).unwrap();
epoll.poll(&mut events, None);

Note that wepoll (and thus this binding) only support sockets, so you can't use arbitrary file descriptors.

License

All source code in this repository is licensed under the Mozilla Public License version 2.0, unless stated otherwise. A copy of this license can be found in the file "LICENSE".

Dependencies

~240KB