Crates.io | wepoll-binding |
lib.rs | wepoll-binding |
version | 3.0.0 |
source | src |
created_at | 2019-04-05 22:32:01.365396 |
updated_at | 2020-10-02 14:54:53.641572 |
description | Safe bindings to the wepoll library |
homepage | |
repository | https://gitlab.com/yorickpeterse/wepoll-binding |
max_upload_size | |
id | 126059 |
size | 33,848 |
Safe Rust bindings for wepoll, using wepoll-sys.
cl.exe
), etcAdd 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.
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".