#mio #demo #work-in-progress #learning #networking

nightly iryna

A lightweight network library based on mio(work-in-progress)

1 unstable release

Uses old Rust 2015

0.1.4 Jan 12, 2018
0.1.3 Jan 5, 2018
0.1.2 Jan 4, 2018
0.1.1 Jan 4, 2018
0.1.0 Jan 4, 2018

#10 in #work-in-progress

MIT license

17KB
417 lines

Iryna

crates

  • work in progress
  • based on mio
  • for learning rust

TODO

  • channel close detect
  • shutdown server gracefully
  • deserializer & delimiter
  • initiative to send

DEMO

An echo service

    use std;
    use channel::*;
    use acceptor::*;

    #[test]
    fn it_works() {
        Acceptor::new()
            .worker_count(4)
            .bind("127.0.0.1", 9098)
            .opt_nodelay(true)
            .opt_send_buf_size(4096)
            .opt_recv_buf_size(4096)
            .on_receive(|ref mut ch| {
                let sbuf: String = ch.read_test();
                match sbuf.trim_right() {
                    "quit" => {
                        ch.close();
                    }
                    _ => {
                        ch.write(sbuf.as_bytes());
                    }
                }
            })
            .on_ready(|ref mut ch| {
                ch.write("Welcome.\n".as_bytes());
            })
            .accept();
        std::thread::sleep_ms(100000);
    }

Dependencies

~2MB
~30K SLoC