#event #async-io #libevent

td_revent

Event library for Rust, Async IO similar to libevent

13 releases

Uses old Rust 2015

0.3.2 May 13, 2022
0.2.2 Apr 19, 2018
0.2.1 Dec 19, 2017
0.2.0 Oct 27, 2017
0.1.0 Mar 31, 2016

#5 in #libevent

Download history 6/week @ 2023-10-18 10/week @ 2023-10-25 31/week @ 2023-11-01 8/week @ 2023-11-08 22/week @ 2023-11-15 23/week @ 2023-11-22 32/week @ 2023-11-29 17/week @ 2023-12-06 19/week @ 2023-12-13 19/week @ 2023-12-20 31/week @ 2023-12-27 4/week @ 2024-01-03 5/week @ 2024-01-10 13/week @ 2024-01-17 23/week @ 2024-01-24 16/week @ 2024-01-31

58 downloads per month
Used in 2 crates

MIT/Apache

130KB
3K SLoC

Event - Async IO similar to libevent

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:

##Usage

To use td_revent, first add this to your Cargo.toml:

[dependencies]
td_revent = "0.3.0"

Then, add this to your crate root:

extern crate td_revent;

Add empty event just do

extern crate td_revent;
use td_revent::EventLoop;

fn main() {
    let mut event_loop = EventLoop::new().unwrap();
    event_loop.run();
}

Add simple timer event just do

extern crate td_revent;
use td_revent::{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 event_loop : EventLoop = EventLoop::new().unwrap();
    event_loop.add_timer(EventEntry::new_timer(100, false, Some(time_callback), None));
    event_loop.add_timer(EventEntry::new_timer(200, true, Some(time_callback), None));
    event_loop.run().unwrap();
}

##Features

Event loop backed by epoll, windows by select. Non-blocking TCP sockets High performance timer system

##Platforms Currently, td_revent only supports Linux and Windows. The goal is to support all platforms that support Rust and the readiness IO model.

Dependencies

~3MB
~61K SLoC