Event is a lightweight IO library for Rust with a focus on adding as little overhead as possible over the OS abstractions.
Build Status
Getting started guide Currently a work in progress:
To use td_revent, first add this to your Cargo.toml:
rust
[dependencies]
td_revent = "0.1.1"
Then, add this to your crate root:
rust
extern crate td_revent;
Add empty event just do ```rust extern crate tdrevent; use tdrevent::EventLoop;
fn main() { let mut eventloop = EventLoop::new().unwrap(); eventloop.run(); } ``` Add simple timer event just do
```rust extern crate tdrevent; use tdrevent::{EventLoop, EventEntry, EventFlags}; use std::ptr;
fn time_callback(ev : &mut EventLoop, fd : u64, _ : EventFlags, data : *mut ()) -> i32 { println!("fd is {:?}", fd); //return 0 status ok other will delete the timer 0 }
pub fn main() { let mut eventloop : EventLoop = EventLoop::new().unwrap(); eventloop.addtimer(EventEntry::newtimer(100, false, Some(timecallback), None)); eventloop.addtimer(EventEntry::newtimer(200, true, Some(timecallback), None)); eventloop.run().unwrap(); } ```
Event loop backed by epoll, windows by select. Non-blocking TCP sockets High performance timer system
Currently, td_revent only supports Linux and Windows. The goal is to support all platforms that support Rust and the readiness IO model.