diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index b8344cb..726ec61 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -85,7 +85,7 @@ jobs:
with:
rust-version: ${{ matrix.rust }}
- name: Test
- run: cargo test
+ run: cargo test --all-features
publish-docs:
if: github.ref == 'refs/heads/main'
@@ -97,7 +97,7 @@ jobs:
- uses: actions/checkout@v2
- name: Generate Docs
run: |
- cargo doc --no-deps
+ cargo doc --no-deps --all-features
echo "" > target/doc/index.html
- name: Publish
uses: peaceiris/actions-gh-pages@v3
@@ -118,4 +118,4 @@ jobs:
shell: bash
run: cargo publish --token ${{ env.CRATES_TOKEN }}
env:
- CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }}
\ No newline at end of file
+ CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }}
diff --git a/src/client.rs b/src/client.rs
index 796cbb8..fe96edb 100644
--- a/src/client.rs
+++ b/src/client.rs
@@ -6,8 +6,8 @@ use hyper::{
};
use pin_project_lite::pin_project;
use std::{
- io,
future::Future,
+ io,
path::{Path, PathBuf},
pin::Pin,
task::{Context, Poll},
@@ -23,10 +23,7 @@ pin_project! {
}
impl UnixStream {
- async fn connect
(path: P) -> std::io::Result
- where
- P: AsRef,
- {
+ async fn connect(path: impl AsRef) -> io::Result {
let unix_stream = tokio::net::UnixStream::connect(path).await?;
Ok(Self { unix_stream })
}
@@ -40,9 +37,11 @@ impl tokio::io::AsyncWrite for UnixStream {
) -> Poll> {
self.project().unix_stream.poll_write(cx, buf)
}
+
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> {
self.project().unix_stream.poll_flush(cx)
}
+
fn poll_shutdown(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> {
self.project().unix_stream.poll_shutdown(cx)
}
@@ -80,16 +79,20 @@ impl Unpin for UnixConnector {}
impl Service for UnixConnector {
type Response = UnixStream;
- type Error = std::io::Error;
- type Future = Pin> + Send + 'static>>;
+ type Error = io::Error;
+ #[allow(clippy::type_complexity)]
+ type Future =
+ Pin> + Send + 'static>>;
+
fn call(&mut self, req: Uri) -> Self::Future {
let fut = async move {
- let path = parse_socket_path(req)?;
+ let path = parse_socket_path(&req)?;
UnixStream::connect(path).await
};
Box::pin(fut)
}
+
fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll> {
Poll::Ready(Ok(()))
}
@@ -101,7 +104,7 @@ impl Connection for UnixStream {
}
}
-fn parse_socket_path(uri: Uri) -> Result {
+fn parse_socket_path(uri: &Uri) -> Result {
if uri.scheme_str() != Some("unix") {
return Err(io::Error::new(
io::ErrorKind::InvalidInput,
@@ -138,6 +141,7 @@ pub trait UnixClientExt {
///
/// let client = Client::unix();
/// ```
+ #[must_use]
fn unix() -> Client {
Client::builder().build(UnixConnector)
}
diff --git a/src/lib.rs b/src/lib.rs
index 48c41b4..0a64652 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -4,6 +4,7 @@
rust_2018_idioms,
missing_docs
)]
+#![warn(clippy::all, clippy::pedantic)]
//! `hyperlocal` provides [Hyper](http://github.com/hyperium/hyper) bindings
//! for [Unix domain sockets](https://github.com/tokio-rs/tokio/tree/master/tokio-net/src/uds/).
diff --git a/src/server.rs b/src/server.rs
index 6c9630a..c477e17 100644
--- a/src/server.rs
+++ b/src/server.rs
@@ -25,6 +25,9 @@ pub(crate) mod conn {
impl SocketIncoming {
/// Creates a new `SocketIncoming` binding to provided socket path.
+ ///
+ /// # Errors
+ /// Refer to [`tokio::net::Listener::bind`](https://docs.rs/tokio/1.15.0/tokio/net/struct.UnixListener.html#method.bind).
pub fn bind(path: impl AsRef) -> Result {
let listener = UnixListener::bind(path)?;
@@ -50,7 +53,8 @@ pub(crate) mod conn {
self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll