#poll #windows #epoll #wepoll

wepoll-binding

Safe bindings to the wepoll library

6 stable releases

✓ Uses Rust 2018 edition

1.0.5 Nov 21, 2019
1.0.4 Apr 6, 2019
1.0.1 Apr 5, 2019

#25 in Windows APIs

Download history 33/week @ 2019-08-06 12/week @ 2019-08-13 8/week @ 2019-08-20 30/week @ 2019-08-27 21/week @ 2019-09-03 28/week @ 2019-09-10 62/week @ 2019-09-17 12/week @ 2019-09-24 27/week @ 2019-10-01 10/week @ 2019-10-08 8/week @ 2019-10-15 18/week @ 2019-10-22 6/week @ 2019-10-29 8/week @ 2019-11-05 16/week @ 2019-11-12

86 downloads per month

MPL-2.0 license

16KB
298 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 = "^1.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

~0.1–1.6MB
~33K SLoC