1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
//! A fast IO library for Rust focusing on non-blocking APIs, event //! notification, and other useful utilties for building high performance IO //! apps. //! //! ## Usage //! //! First, add this to your `Cargo.toml`: //! //! ```toml //! [dependencies] //! soio = "0.1" //! ``` //! //! Then, add this to your crate root: //! //! ```rust //! extern crate soio; //! ``` //! //! # Example //! //! ``` //! use soio::{Events, Poll, Ready, PollOpt, Token}; //! use soio::tcp::{TcpListener, TcpStream}; //! //! // Setup some tokens to allow us to identify which event is //! // for which socket. //! const SERVER: Token = Token(0); //! const CLIENT: Token = Token(1); //! //! // Setup the server socket //! let server = TcpListener::bind("127.0.0.1:13265").unwrap(); //! //! // Create an poll instance //! let poll = Poll::new().unwrap(); //! //! // Start listening for incoming connections //! poll.register(&server, SERVER, Ready::readable(), //! PollOpt::edge()).unwrap(); //! //! // Setup the client socket //! let sock = TcpStream::connect("127.0.0.1:13265").unwrap(); //! //! // Register the socket //! poll.register(&sock, CLIENT, Ready::readable(), //! PollOpt::edge()).unwrap(); //! //! // Create storage for events //! let mut events = Events::with_capacity(1024); //! //! loop { //! poll.poll(&mut events, None).unwrap(); //! //! for event in events.iter() { //! match event.token() { //! SERVER => { //! // Accept and drop the socket immediately, this will close //! // the socket and notify the client of the EOF. //! let _ = server.accept(); //! } //! CLIENT => { //! // The server just shuts down the socket, let's just exit //! // from our event loop. //! return; //! } //! _ => unreachable!(), //! } //! } //! } //! //! ``` extern crate libc; #[macro_use] extern crate log; mod sys; mod net; mod io; mod iovec; mod event; mod evented; mod ready; mod poll; mod poll_opt; mod registration; mod token; pub mod channel; pub use iovec::IoVec; pub use net::{ tcp, udp, }; pub use event::{ Event, Events, }; pub use evented::Evented; pub use ready::Ready; pub use poll::Poll; pub use poll_opt::PollOpt; pub use registration::{ Registration, SetReadiness, }; pub use token::Token; pub use sys::EventedFd;