tokio_dns/lib.rs
1//! This crate offers tools for asynchronous name resolution, and extensions to
2//! the `tokio_core` crate.
3//!
4//! First, `Endpoint` and `ToEndpoint` behave very much like `SocketAddr` and
5//! `ToSocketAddrs` from the standard library. The main difference is that the
6//! `ToEndpoint` trait does not perform any name resolution. If simply detect
7//! whether the given endpoint is a socket address or a host name. Then, it
8//! is up to a resolver to perform name resolution.
9//!
10//! The `Resolver` trait describes an abstract, asynchronous resolver. This crate
11//! provides one (for now) implementation of a resolver, the `CpuPoolResolver`.
12//! It uses a thread pool and the `ToSocketAddrs` trait to perform name resolution.
13//!
14//! The crate level functions `tcp_connect`, `tcp_listen` and `udp_bind` support
15//! name resolution via a lazy static `CpuPoolResolver` using 5 threads. Their
16//!`*_with` counterpart take a resolver as an argument.
17//!
18//! [Git Repository](https://github.com/sbstp/tokio-dns)
19#![warn(missing_docs)]
20
21extern crate futures;
22extern crate futures_cpupool;
23extern crate tokio;
24
25#[macro_use]
26extern crate lazy_static;
27
28mod endpoint;
29mod net;
30mod resolver;
31
32use std::io;
33
34use futures::future::Future;
35
36/// An alias for the futures produced by this library.
37pub type IoFuture<T> = Box<Future<Item = T, Error = io::Error> + Send>;
38
39fn boxed<F>(fut: F) -> Box<Future<Item = F::Item, Error = F::Error> + Send>
40where
41 F: Future + Send + 'static,
42{
43 Box::new(fut)
44}
45
46pub use endpoint::{Endpoint, ToEndpoint};
47#[allow(deprecated)]
48pub use net::{
49 resolve, resolve_ip_addr, resolve_ip_addr_with, resolve_sock_addr, resolve_sock_addr_with,
50 TcpListener, TcpStream, UdpSocket,
51};
52pub use resolver::{CpuPoolResolver, Resolver};