Skip to content

Commit 9548b0f

Browse files
committed
Document that the client/server features are not opt-in
Adds documentation for the switch to the `client` and `server` features now being opt-in, rather than enabled by default (see softprops#54). I experimented with also enabling the nightly-only `doc_cfg` / `doc_auto_cfg` features (see rust-lang/rust/issues/43781, which can be used on `docs.rs` since it builds docs with nightly), however: - the features don't currently work well with the re-exports in the crate root, so require every struct/trait to be manually annotated. - the rendering isn't great - the crate landing page wrapping ended up broken So for now it seems best to not use that. I did adjust the `docs.rs` config in `Cargo.toml` to ensure docs are actually generated for all features, since previously the docs were almost empty. I also fixed a few typos / markdown syntax errors.
1 parent 2ee4d14 commit 9548b0f

File tree

6 files changed

+30
-18
lines changed

6 files changed

+30
-18
lines changed

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,6 @@ required-features = ["server", "hyper/runtime"]
4141
[[test]]
4242
name = "server_client"
4343
required-features = ["client", "server", "hyper/runtime"]
44+
45+
[package.metadata.docs.rs]
46+
all-features = true

README.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,21 @@ not needed. Examples of Unix daemons that provide this kind of host local interf
4343

4444
## Installation
4545

46-
Add the following to your `Cargo.toml` file
46+
By default `hyperlocal` does not enable any [feature flags](https://doc.rust-lang.org/cargo/reference/features.html),
47+
so you will need to enable the appropriate features for your use-case.
48+
49+
For server usage, add the following to your `Cargo.toml` file:
50+
51+
```toml
52+
[dependencies]
53+
hyperlocal = { version = "0.8", features = ["server"] }
54+
```
55+
56+
Or for client usage:
4757

4858
```toml
4959
[dependencies]
50-
hyperlocal = "0.8"
60+
hyperlocal = { version = "0.8", features = ["client"] }
5161
```
5262

5363
## Usage
@@ -103,7 +113,7 @@ It's a Unix system. I know this.
103113
Configure your `Hyper` client using `hyper::Client::builder()`.
104114
105115
Hyper's client interface makes it easy to send typical HTTP methods like `GET`, `POST`, `DELETE` with factory
106-
methods, `get`, `post`, `delete`, etc. These require an argument that can be tranformed into a `hyper::Uri`.
116+
methods, `get`, `post`, `delete`, etc. These require an argument that can be transformed into a `hyper::Uri`.
107117
108118
Since Unix domain sockets aren't represented with hostnames that resolve to ip addresses coupled with network ports,
109119
your standard over the counter URL string won't do. Instead, use a `hyperlocal::Uri`, which represents both file path to the domain

src/client.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl tokio::io::AsyncRead for UnixStream {
5757
}
5858
}
5959

60-
/// the `[UnixConnector]` can be used to construct a `[hyper::Client]` which can
60+
/// The [`UnixConnector`] can be used to construct a [`hyper::Client`] which can
6161
/// speak to a unix domain socket.
6262
///
6363
/// # Example
@@ -70,8 +70,8 @@ impl tokio::io::AsyncRead for UnixStream {
7070
/// ```
7171
///
7272
/// # Note
73-
/// If you don't need access to the low-level `[hyper::Client]` builder
74-
/// interface, consider using the `[UnixClientExt]` trait instead.
73+
/// If you don't need access to the low-level [`hyper::Client`] builder
74+
/// interface, consider using the [`UnixClientExt`] trait instead.
7575
#[derive(Clone, Copy, Debug, Default)]
7676
pub struct UnixConnector;
7777

@@ -129,7 +129,7 @@ fn parse_socket_path(uri: &Uri) -> Result<PathBuf, io::Error> {
129129
}
130130
}
131131

132-
/// Extention trait for constructing a hyper HTTP client over a Unix domain
132+
/// Extension trait for constructing a hyper HTTP client over a Unix domain
133133
/// socket.
134134
pub trait UnixClientExt {
135135
/// Construct a client which speaks HTTP over a Unix domain socket

src/lib.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,21 @@
99
//! `hyperlocal` provides [Hyper](http://github.com/hyperium/hyper) bindings
1010
//! for [Unix domain sockets](https://github.com/tokio-rs/tokio/tree/master/tokio-net/src/uds/).
1111
//!
12-
//! See the [`UnixClientExt`] docs for
13-
//! how to configure clients.
12+
//! See the [`UnixClientExt`] docs for how to configure clients.
1413
//!
15-
//! See the
16-
//! [`UnixServerExt`] docs for how to
17-
//! configure servers.
14+
//! See the [`UnixServerExt`] docs for how to configure servers.
1815
//!
1916
//! The [`UnixConnector`] can be used in the [`hyper::Client`] builder
2017
//! interface, if required.
2118
//!
2219
//! # Features
2320
//!
24-
//! - Client- enables the client extension trait and connector. *Enabled by
25-
//! default*.
21+
//! By default `hyperlocal` does not enable any [feature flags](https://doc.rust-lang.org/cargo/reference/features.html).
2622
//!
27-
//! - Server- enables the server extension trait. *Enabled by default*.
23+
//! The following features are available:
24+
//!
25+
//! - **`client`** — Enables the client extension trait and connector.
26+
//! - **`server`** — Enables the server extension trait.
2827
2928
#[cfg(feature = "client")]
3029
mod client;

src/server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub(crate) mod conn {
3434
Ok(Self { listener })
3535
}
3636

37-
/// Creates a new `SocketIncoming` from Tokio's `UnixListener`
37+
/// Creates a new `SocketIncoming` from Tokio's [`UnixListener`].
3838
///
3939
/// ```rust,ignore
4040
/// let socket = SocketIncoming::from_listener(unix_listener);

src/uri.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use hyper::Uri as HyperUri;
22
use std::path::Path;
33

4-
/// A convenience type that can be used to construct Unix Domain Socket URIs
4+
/// A convenience type that can be used to construct Unix Domain Socket URIs.
55
///
66
/// This type implements `Into<hyper::Uri>`.
77
///
@@ -18,7 +18,7 @@ pub struct Uri {
1818
}
1919

2020
impl Uri {
21-
/// Create a new `[Uri]` from a socket address and a path
21+
/// Create a new [`Uri`] from a socket address and a path.
2222
///
2323
/// # Panics
2424
/// Will panic if path is not absolute and/or a malformed path string.

0 commit comments

Comments
 (0)