make direct dependency on MIO optional (#78)

This commit is contained in:
Benjamin Fry 2016-12-21 08:39:25 -08:00 committed by GitHub
parent b9ec67eed2
commit 0f696950d9
9 changed files with 51 additions and 6 deletions

View File

@ -2,6 +2,10 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
## 0.9.2
### Changed
- mio_client is now an optional feature in favor of the futures-rs ClientFuture
## 0.9.1
### Changed
- OpenSSL is now an optional feature for the client

4
Cargo.lock generated
View File

@ -17,7 +17,7 @@ dependencies = [
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-core 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"toml 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)",
"trust-dns 0.9.1",
"trust-dns 0.9.2",
]
[[package]]
@ -484,7 +484,7 @@ dependencies = [
[[package]]
name = "trust-dns"
version = "0.9.1"
version = "0.9.2"
dependencies = [
"backtrace 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"chrono 0.2.25 (registry+https://github.com/rust-lang/crates.io-index)",

View File

@ -204,6 +204,31 @@ so this should allow it to work with most internal loads.
$ server/target/release/named --help
```
## Using as a dependency
The Client has a few features which can be disabled for different reasons when embedding in other software.
- openssl
It is a default feature, so default-features will need to be set to false (this will disable all other default features in trust-dns). Until there are other crypto libraries supported, this will also disable DNSSec validation. The functions will still exist, but will always return errors on validation. The below example line will disable all default features and enable OpenSSL, remove `"openssl"` to remove the dependency on OpenSSL.
```
[dependencies]
...
trust-dns = { version = "*", default-features = false, features = ["openssl"] }
```
- mio_client
Also a default feature, this exables the old deprecated MIO based client. This will remove an independent dependency requirement on the MIO library (there is an implicit dependency on MIO via the tokio-rs library, that will not be removed). Disabling this feature will only compile in the futures-rs based client. The below example line will disable all default features and enable mio_client, remove `"mio_client"` to remove the direct dependency on MIO.
```
[dependencies]
...
trust-dns = { version = "*", default-features = false, features = ["mio_client"] }
```
# FAQ
- Why are you building another DNS server?

View File

@ -1,6 +1,6 @@
[package]
name = "trust-dns"
version = "0.9.1"
version = "0.9.2"
authors = ["Benjamin Fry <benjaminfry@me.com>"]
# A short blurb about the package. This is not rendered in any format when
@ -37,7 +37,8 @@ license = "MIT/Apache-2.0"
build = "build.rs"
[features]
default = ["openssl"]
default = ["openssl", "mio_client"]
mio_client = ["mio"]
[lib]
name = "trust_dns"
@ -51,7 +52,7 @@ error-chain = "0.1.12"
futures = "^0.1"
lazy_static = "^0.2.1"
log = "^0.3.5"
mio = "^0.5.1"
mio = { version = "^0.5.1", optional = true }
openssl = { version = "^0.8.3", optional = true }
rand = "^0.3"
rustc-serialize = "^0.3.18"

View File

@ -17,7 +17,9 @@
//! Use `Client` along with `trust_dns::udp::UdpClientConnection` or
//! `trust_dns::tcp::TcpClientConnection`.
#[cfg(feature = "mio_client")]
mod client;
#[cfg(feature = "mio_client")]
mod client_connection;
mod client_future;
mod memoize_client_handle;
@ -26,7 +28,9 @@ mod retry_client_handle;
mod secure_client_handle;
#[allow(deprecated)]
#[cfg(feature = "mio_client")]
pub use self::client::Client;
#[cfg(feature = "mio_client")]
pub use self::client_connection::ClientConnection;
pub use self::client_future::{ClientFuture, BasicClientHandle, ClientHandle, StreamHandle, ClientStreamHandle};
pub use self::memoize_client_handle::MemoizeClientHandle;

View File

@ -33,6 +33,7 @@ extern crate data_encoding;
#[macro_use] extern crate futures;
#[macro_use] extern crate lazy_static;
#[macro_use] extern crate log;
#[cfg(feature = "mio_client")]
extern crate mio;
#[cfg(feature = "openssl")]
extern crate openssl;

View File

@ -16,13 +16,18 @@
//! TCP protocol related components for DNS.
#[cfg(feature = "mio_client")]
mod handler;
#[cfg(feature = "mio_client")]
mod tcp_client_connection;
mod tcp_client_stream;
mod tcp_stream;
#[cfg(feature = "mio_client")]
pub use self::handler::TcpHandler;
#[cfg(feature = "mio_client")]
pub use self::handler::TcpState;
#[cfg(feature = "mio_client")]
pub use self::tcp_client_connection::TcpClientConnection;
pub use self::tcp_client_stream::TcpClientStream;
pub use self::tcp_stream::TcpStream;

View File

@ -16,13 +16,18 @@
//! UDP protocol related components for DNS.
#[cfg(feature = "mio_client")]
mod handler;
#[cfg(feature = "mio_client")]
mod udp_client_connection;
mod udp_client_stream;
mod udp_stream;
#[cfg(feature = "mio_client")]
pub use self::handler::UdpHandler;
#[cfg(feature = "mio_client")]
pub use self::handler::UdpState;
#[cfg(feature = "mio_client")]
pub use self::udp_client_connection::UdpClientConnection;
pub use self::udp_client_stream::UdpClientStream;
pub use self::udp_stream::UdpStream;

View File

@ -63,4 +63,4 @@ rusqlite = "^0.7.3"
time = "^0.1"
tokio-core = "^0.1"
toml = "^0.1"
trust-dns = { version = "0.9.0", path = "../client" }
trust-dns = { version = "^0.9", path = "../client" }