summaryrefslogtreecommitdiffstats
path: root/tokio-util
diff options
context:
space:
mode:
Diffstat (limited to 'tokio-util')
-rw-r--r--tokio-util/Cargo.toml13
-rw-r--r--tokio-util/src/cfg.rs19
-rw-r--r--tokio-util/src/lib.rs13
-rw-r--r--tokio-util/src/udp/frame.rs1
4 files changed, 43 insertions, 3 deletions
diff --git a/tokio-util/Cargo.toml b/tokio-util/Cargo.toml
index 8e5542be..356712c6 100644
--- a/tokio-util/Cargo.toml
+++ b/tokio-util/Cargo.toml
@@ -19,6 +19,16 @@ Additional utilities for working with Tokio.
"""
categories = ["asynchronous"]
+[features]
+# No features on by default
+default = []
+
+# Shorthand for enabling everything
+full = ["codec", "udp"]
+
+codec = []
+udp = ["tokio/udp"]
+
[dependencies]
tokio = { version = "=0.2.0-alpha.6", path = "../tokio" }
@@ -29,10 +39,11 @@ log = "0.4"
pin-project-lite = "0.1.1"
[dev-dependencies]
-tokio = { version = "=0.2.0-alpha.6", path = "../tokio" }
+tokio = { version = "=0.2.0-alpha.6", path = "../tokio", features = ["full"] }
tokio-test = { version = "=0.2.0-alpha.6", path = "../tokio-test" }
futures = "0.3.0"
[package.metadata.docs.rs]
all-features = true
+rustdoc-args = ["--cfg", "docsrs"]
diff --git a/tokio-util/src/cfg.rs b/tokio-util/src/cfg.rs
new file mode 100644
index 00000000..13fabd36
--- /dev/null
+++ b/tokio-util/src/cfg.rs
@@ -0,0 +1,19 @@
+macro_rules! cfg_codec {
+ ($($item:item)*) => {
+ $(
+ #[cfg(feature = "codec")]
+ #[cfg_attr(docsrs, doc(cfg(feature = "codec")))]
+ $item
+ )*
+ }
+}
+
+macro_rules! cfg_udp {
+ ($($item:item)*) => {
+ $(
+ #[cfg(all(feature = "udp", feature = "codec"))]
+ #[cfg_attr(docsrs, doc(cfg(all(feature = "udp", feature = "codec"))))]
+ $item
+ )*
+ }
+}
diff --git a/tokio-util/src/lib.rs b/tokio-util/src/lib.rs
index 5a64673c..d4ed5a7b 100644
--- a/tokio-util/src/lib.rs
+++ b/tokio-util/src/lib.rs
@@ -10,8 +10,17 @@
no_crate_inject,
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
))]
+#![cfg_attr(docsrs, feature(doc_cfg))]
//! Utilities for working with Tokio.
-pub mod codec;
-pub mod udp;
+#[macro_use]
+mod cfg;
+
+cfg_codec! {
+ pub mod codec;
+}
+
+cfg_udp! {
+ pub mod udp;
+}
diff --git a/tokio-util/src/udp/frame.rs b/tokio-util/src/udp/frame.rs
index d37b20cd..a6c6f220 100644
--- a/tokio-util/src/udp/frame.rs
+++ b/tokio-util/src/udp/frame.rs
@@ -27,6 +27,7 @@ use std::task::{Context, Poll};
/// calling `split` on the `UdpFramed` returned by this method, which will break
/// them into separate objects, allowing them to interact more easily.
#[must_use = "sinks do nothing unless polled"]
+#[cfg_attr(docsrs, doc(feature = "codec-udp"))]
#[derive(Debug)]
pub struct UdpFramed<C> {
socket: UdpSocket,