Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various improvements #43

Closed
wants to merge 37 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
80c1c96
remove unused #[macro_use] and #[allow(unused_macros)]
Thomasdezeeuw Nov 29, 2017
fd240e3
sort crate statements
Thomasdezeeuw Nov 29, 2017
57ff4c4
remove unused FnBox trait
Thomasdezeeuw Nov 29, 2017
4718daa
remove unused temporary variable
Thomasdezeeuw Nov 29, 2017
573e1e1
use simple version of io::Error
Thomasdezeeuw Nov 29, 2017
fddc571
replace the try! macro with the try operator ?
Thomasdezeeuw Nov 29, 2017
de9f5d3
change Core.poll to return an io::Result<bool>
Thomasdezeeuw Nov 29, 2017
751ce7b
sort use statements
Thomasdezeeuw Nov 29, 2017
79935a9
run partial rustfmt
Thomasdezeeuw Nov 29, 2017
e92454a
remove unneeded return
Thomasdezeeuw Nov 30, 2017
93c4dfe
remove Evented trait requirement to implement Debug
Thomasdezeeuw Nov 30, 2017
9533774
small code cleanups in PollEvented
Thomasdezeeuw Nov 30, 2017
ad03eb6
small doc cleanups in PollEvented
Thomasdezeeuw Nov 30, 2017
f151137
small code cleanups in IoToken
Thomasdezeeuw Nov 30, 2017
eacf852
small doc cleanups in IoToken
Thomasdezeeuw Nov 30, 2017
d2e5f31
small doc cleanups in Core
Thomasdezeeuw Nov 30, 2017
09b5a20
small code cleanups in Core
Thomasdezeeuw Nov 30, 2017
51d7080
improve crate level documentation
Thomasdezeeuw Nov 30, 2017
35200a1
rewrite SendDgram's and RecvDgram's poll functions
Thomasdezeeuw Nov 30, 2017
250199d
improvements to the UdpSocket documentation
Thomasdezeeuw Nov 30, 2017
fc60a10
documentation improvements to UdpFramed and UdpCodec
Thomasdezeeuw Nov 30, 2017
1676930
add more keywords to the categories in Cargo.toml
Thomasdezeeuw Dec 1, 2017
503d368
update reactor module level documentation
Thomasdezeeuw Dec 1, 2017
16f2819
expand Handle and Remote documentation
Thomasdezeeuw Dec 1, 2017
41f162a
expand net module documentation
Thomasdezeeuw Dec 1, 2017
e086c7e
update TcpListener documentation
Thomasdezeeuw Dec 1, 2017
305caef
remove mention of none-existing future R
Thomasdezeeuw Dec 1, 2017
0db5708
various small code cleanups in net/tcp
Thomasdezeeuw Dec 1, 2017
25f7858
rewrite TcpStreamNewState poll implementation
Thomasdezeeuw Dec 1, 2017
3951757
improve documentation of TcpStream
Thomasdezeeuw Dec 1, 2017
bfc61e2
return a TcpStreamNew for connect_stream
Thomasdezeeuw Dec 1, 2017
cd665df
fix unused result error in net/tcp
Thomasdezeeuw Dec 1, 2017
4357331
derive Debug on all public structs
Thomasdezeeuw Dec 1, 2017
3f73a54
add warning about missing debug implementations
Thomasdezeeuw Dec 1, 2017
221fcbb
remove unused import
Thomasdezeeuw Dec 1, 2017
64c98d7
Fix clippy complaints
Thomasdezeeuw Dec 1, 2017
22a8ac1
expand travis support
Thomasdezeeuw Dec 1, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,26 @@
---
language: rust
sudo: false

cache: cargo
os:
- linux
- osx
language: rust
rust:
- stable
- beta
- nightly

before_script:
- pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH

script:
- cargo build
- cargo test
- cargo --version
- rustc --version
- cargo build --verbose
- cargo test --verbose
- cargo doc --no-deps

after_success:
- travis-cargo --only nightly doc-upload --branch new-crate

env:
global:
- secure: iwlN1zfUCp/5BAAheqIRSFIqiM9zSwfIGcVDw/V7jHveqXyNzmCs7H58/cd90WLqonqpPX0t5GF66oTjms4v0DFjgXr/k4358qeSZaV082V3baNrVpCDHeCQV0SvKsfiYxDDJGSUL1WIUP+tqqDm4+ksZQP3LnwZojkABjWz5CBNt4kX+Wz5ZbYqtQoxyuZba5UyPY2CXJtubvCVPGMJULuUpklYxXZ4dWM2olzGgVJ8rE8udhSZ4ER4JgxB0KUx3/5TwHHzgyPEsWR4bKN6JzBjIczQofXUcUXXdoZBs23H/VhCpzKcn3/oJ8btVYPzwtdj5FmVB1aVR/gjPo2bSGi/sofq+LwL/1HJXkM+kjl8m2dLLcDBKqNYNERtVA1++LhkMWAFRgGYe8v8Ryxjiue1NF5LgAIA/fjK0uI1DELTzTf/TKrM+AtPDNTvhOft4/YD+hoImjwk6nv6PBb2TiTYnc79Qf4AZ65tv1qtsAUPuw4plLaccHQAO4ldYVXn4u9c+iisJwvovs6jo06bF3U3qtdI5gXsrI9+T25TrXvYb+IREo0MHzYEM0KlPFnscEArzC3eajuSd36ARFP3lDc+gp2RPs89iJjowms0eRyepp7Cu6XO3Cd2pfAX8AqvnmttZf4Nm51ONeiBPXPXItUkJm49MCpMJywU1IZcWZg=

notifications:
email:
on_success: never

os:
- linux
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ description = """
Core I/O and event loop primitives for asynchronous I/O in Rust. Foundation for
the rest of the tokio crates.
"""
categories = ["asynchronous"]
categories = ["asynchronous", "I/O", "none-blocking"]

[badges]
travis-ci = { repository = "tokio-rs/tokio" }
Expand Down
1 change: 0 additions & 1 deletion examples/echo-udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
//! Each line you type in to the `nc` terminal should be echo'd back to you!

extern crate futures;
#[macro_use]
extern crate tokio;
#[macro_use]
extern crate tokio_io;
Expand Down
47 changes: 27 additions & 20 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
//! `Future`-powered I/O at the core of Tokio
//!
//! This crate uses the `futures` crate to provide an event loop ("reactor
//! This crate uses the [`futures`] crate to provide an event loop ("reactor
//! core") which can be used to drive I/O like TCP and UDP. All asynchronous I/O
//! is powered by the `mio` crate.
//! is powered by the [`mio`] crate.
//!
//! [`futures`]: ../futures/index.html
//! [`mio`]: ../mio/index.html
//!
//! The concrete types provided in this crate are relatively bare bones but are
//! intended to be the essential foundation for further projects needing an
//! event loop. In this crate you'll find:
//!
//! * TCP, both streams and listeners
//! * UDP sockets
//! * An event loop to run futures
//! * TCP, both streams and listeners.
//! * UDP sockets.
//! * An event loop to run futures.
//!
//! More functionality is likely to be added over time, but otherwise the crate
//! is intended to be flexible, with the `PollEvented` type accepting any
//! type that implements `mio::Evented`. For example, the `tokio-uds` crate
//! uses `PollEvented` to provide support for Unix domain sockets.
//! is intended to be flexible, with the [`PollEvented`] type accepting any
//! type that implements [`mio::Evented`]. For example, the [`tokio-uds`] crate
//! uses [`PollEvented`] to provide support for Unix domain sockets.
//!
//! [`PollEvented`]: ./reactor/struct.PollEvented.html
//! [`mio::Evented`]: ../mio/event/trait.Evented.html
//! [`tokio-uds`]: https://crates.io/crates/tokio-uds
//!
//! Some other important tasks covered by this crate are:
//!
Expand Down Expand Up @@ -45,60 +52,60 @@
//! use tokio::reactor::Core;
//!
//! fn main() {
//! // Create the event loop that will drive this server
//! // Create the event loop that will drive this server.
//! let mut core = Core::new().unwrap();
//! let handle = core.handle();
//!
//! let pool = CpuPool::new_num_cpus();
//!
//! // Bind the server's socket
//! // Bind the server's socket.
//! let addr = "127.0.0.1:12345".parse().unwrap();
//! let listener = TcpListener::bind(&addr, &handle).unwrap();
//! let listener = TcpListener::bind(&addr, &handle)
//! .expect("unable to bind TCP listener");
//!
//! // Pull out a stream of sockets for incoming connections
//! let server = listener.incoming().for_each(|(sock, _)| {
//! // Split up the reading and writing parts of the
//! // socket
//! // socket.
//! let (reader, writer) = sock.split();
//!
//! // A future that echos the data and returns how
//! // many bytes were copied...
//! let bytes_copied = copy(reader, writer);
//!
//! // ... after which we'll print what happened
//! // ... after which we'll print what happened.
//! let handle_conn = bytes_copied.map(|amt| {
//! println!("wrote {:?} bytes", amt)
//! }).map_err(|err| {
//! println!("IO error {:?}", err)
//! eprintln!("IO error {:?}", err)
//! });
//!
//! // Spawn the future as a concurrent task
//! // Spawn the future as a concurrent task.
//! pool.execute(handle_conn).unwrap();
//!
//! Ok(())
//! });
//!
//! // Spin up the server on the event loop
//! // Spin up the server on the event loop.
//! core.run(server).unwrap();
//! }
//! ```

#![doc(html_root_url = "https://docs.rs/tokio-core/0.1")]
#![deny(missing_docs)]
#![warn(missing_debug_implementations)]
#![deny(warnings)]
#![allow(unused_macros)]

extern crate bytes;
#[macro_use]
extern crate futures;
extern crate iovec;
#[macro_use]
extern crate log;
extern crate mio;
extern crate slab;
#[macro_use]
extern crate tokio_io;

#[macro_use]
extern crate log;

pub mod net;
pub mod reactor;
41 changes: 38 additions & 3 deletions src/net/mod.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,46 @@
//! TCP/UDP bindings for `tokio-core`
//! TCP/UDP bindings for `tokio`.
//!
//! This module contains the TCP/UDP networking types, similar to the standard
//! library, which can be used to implement networking protocols.
//!
//! # TCP
//!
//! Connecting to an address, via TCP, can be done using [`TcpStream`]'s
//! [`connect`] method, which returns [`TcpStreamNew`]. `TcpStreamNew`
//! implements a future which returns a `TcpStream`.
//!
//! To listen on an address [`TcpListener`] can be used. `TcpListener`'s
//! [`incoming`][incoming_method] method can be used to accept new connections.
//! It return the [`Incoming`] struct, which implements a stream which returns
//! `TcpStream`s.
//!
//! [`TcpStream`]: struct.TcpStream.html
//! [`connect`]: struct.TcpStream.html#method.connect
//! [`TcpStreamNew`]: struct.TcpStreamNew.html
//! [`TcpListener`]: struct.TcpListener.html
//! [incoming_method]: struct.TcpListener.html#method.incoming
//! [`Incoming`]: struct.Incoming.html
//!
//! # UDP
//!
//! The main struct for UDP is the [`UdpSocket`], which represents a UDP socket.
//! Reading and writing to it can be done using futures, which return the
//! [`RecvDgram`] and [`SendDgram`] structs respectively.
//!
//! For convience it's also possible to convert raw datagrams into higher-level
//! frames. This done with [`UdpFramed`], created by calling [`framed`] on a
//! [`UdpSocket`], and using the [`UdpCodec`].
//!
//! [`UdpSocket`]: struct.UdpSocket.html
//! [`RecvDgram`]: struct.RecvDgram.html
//! [`SendDgram`]: struct.SendDgram.html
//! [`UdpFramed`]: struct.UdpFramed.html
//! [`framed`]: struct.UdpSocket.html#method.framed
//! [`UdpCodec`]: trait.UdpCodec.html

mod tcp;
mod udp;

pub use self::tcp::{TcpStream, TcpStreamNew};
pub use self::tcp::{TcpListener, Incoming};
pub use self::udp::{UdpSocket, UdpCodec, UdpFramed, SendDgram, RecvDgram};
pub use self::tcp::{Incoming, TcpListener};
pub use self::udp::{RecvDgram, SendDgram, UdpCodec, UdpFramed, UdpSocket};
Loading