Crate epoll_rs

Source
Expand description

A rusty wrapper for Linux’s epoll interface that is easy to use and hard to misuse.

Create a new epoll instance with Epoll::new. Add any struct that implements the OwnedRawFd trait with Epoll::add. epoll::add returns a Token that takes ownership of the added file.

use epoll_rs::{Epoll, Opts};
let mut epoll = Epoll::new()?;
let token = epoll.add(file, Opts::IN)?;

Tokens returned from one epoll instance cannot be used with another instance. Doing so will cause a panic in debug mode and undefined behavior in release mode.

use epoll_rs::{Epoll, Opts};
let mut epoll1 = Epoll::new()?;
let mut epoll2 = Epoll::new()?;
let token1 = epoll1.add(file, Opts::IN)?;
let res = epoll2.remove(token1); // <- undefined behavior in release mode

Structs§

Epoll
Rust abstraction atop linux’s epoll interface. Wrapper type around an epoll file descriptor. Performs proper cleanup on drop.
EpollEvent
An event, such as that a file is available for reading. Transmute compatible with libc::epoll_event
Opts
Options used in adding a file or modifying a previously added file
Token
Opaque type used to refer to single files registered with an epoll instance

Traits§

OwnedRawFd
A trait for all structs that wrap a unix file descriptor.