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
//! A wrapper around mio::Poll that helps with sharing time in a single thread. The core of the library is the run() function. run() never returns
//! and the thread spends the rest of its life collecting events from an MIO poll and dispatching them.
//!
//! To use the high-level interface:
//! 1. Create a BufferedTransport from whatever IO object you want to do IO with
//! 2. Create a Notifiable and register it with your BufferedTransport using set_notify()
//! 3. Call transportation::run()
//! 4. Your notifiable will get notified when there's data. (Your notifiable should keep its own copy of the BufferedTransport so it can get at the
//! data)
//!
//! To use the low-level interface:
//! 1. Create a type that implements Notifiable ( An Fn() -> () closure is great for this )
//! 2. Register an instance of your type with the reactor using insert_listener()
//! 3. Use the usize returned by insert_listener() as an Mio::token() to register with the mio::Poll from borrow_poll(). Get your types from the
//! re-exported mio crate to ensure the versions match.
//! 4. When mio generates events for your token, transportation will call your instance's
//! notify() function. Get a copy of the current event by calling get_event()

pub extern crate mio;
#[cfg(unix)]
extern crate nix;
#[cfg(feature = "encrypt")]
extern crate num;
#[cfg(feature = "encrypt")]
pub extern crate ring;
#[cfg(feature = "protocol")]
extern crate serde;
#[cfg(feature = "protocol")]
extern crate serde_cbor;
#[cfg(feature = "encrypt")]
pub extern crate untrusted; // Seems bizzare that ring itself does not reexport untrusted.
#[macro_use]
extern crate log;
#[macro_use]
#[cfg(feature = "encrypt")]
extern crate lazy_static;
extern crate byteorder;
#[cfg(feature = "protocol")]
extern crate libflate;

mod buffered_transport;
#[cfg(feature = "encrypt")]
mod encrypt;
#[cfg(feature = "encrypt")]
mod encrypted_transport;
#[cfg(unix)]
mod fd_adapter;
mod message_transport;
mod notify;
#[cfg(feature = "protocol")]
mod protocol_transport;
mod scheduler;
#[cfg(unix)]
mod signals;
mod transport;

pub use buffered_transport::BufferedTransport;
#[cfg(feature = "encrypt")]
pub use encrypted_transport::EncryptedTransport;
#[cfg(feature = "encrypt")]
pub use encrypted_transport::EncryptionPerspective;
pub use message_transport::MessageTransport;
pub use notify::{Notifiable, Notifies};
#[cfg(feature = "protocol")]
pub use protocol_transport::ProtocolTransport;
pub use scheduler::{borrow_poll, get_event, insert_listener, remove_listener, run, set_timeout};
#[cfg(unix)]
pub use signals::get_signal_name;
#[cfg(unix)]
pub use signals::set_signal_handler;
pub use transport::Transport;

#[cfg(feature = "encrypt")]
lazy_static! {
	pub static ref RNG: ring::rand::SystemRandom = ring::rand::SystemRandom::new();
}