Skip to content

Commit 2ee4d14

Browse files
authored
Merge pull request softprops#55 from onalante-msft/misc-clippy
2 parents 7a2cbb8 + b29beff commit 2ee4d14

File tree

5 files changed

+26
-13
lines changed

5 files changed

+26
-13
lines changed

.github/workflows/main.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ jobs:
8585
with:
8686
rust-version: ${{ matrix.rust }}
8787
- name: Test
88-
run: cargo test
88+
run: cargo test --all-features
8989

9090
publish-docs:
9191
if: github.ref == 'refs/heads/main'
@@ -97,7 +97,7 @@ jobs:
9797
- uses: actions/checkout@v2
9898
- name: Generate Docs
9999
run: |
100-
cargo doc --no-deps
100+
cargo doc --no-deps --all-features
101101
echo "<meta http-equiv=refresh content=0;url=`echo ${{ github.repository }} | cut -d / -f 2 | tr '-' '_'`/index.html>" > target/doc/index.html
102102
- name: Publish
103103
uses: peaceiris/actions-gh-pages@v3
@@ -118,4 +118,4 @@ jobs:
118118
shell: bash
119119
run: cargo publish --token ${{ env.CRATES_TOKEN }}
120120
env:
121-
CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }}
121+
CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }}

src/client.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use hyper::{
66
};
77
use pin_project_lite::pin_project;
88
use std::{
9-
io,
109
future::Future,
10+
io,
1111
path::{Path, PathBuf},
1212
pin::Pin,
1313
task::{Context, Poll},
@@ -23,10 +23,7 @@ pin_project! {
2323
}
2424

2525
impl UnixStream {
26-
async fn connect<P>(path: P) -> std::io::Result<Self>
27-
where
28-
P: AsRef<Path>,
29-
{
26+
async fn connect(path: impl AsRef<Path>) -> io::Result<Self> {
3027
let unix_stream = tokio::net::UnixStream::connect(path).await?;
3128
Ok(Self { unix_stream })
3229
}
@@ -40,9 +37,11 @@ impl tokio::io::AsyncWrite for UnixStream {
4037
) -> Poll<Result<usize, io::Error>> {
4138
self.project().unix_stream.poll_write(cx, buf)
4239
}
40+
4341
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), io::Error>> {
4442
self.project().unix_stream.poll_flush(cx)
4543
}
44+
4645
fn poll_shutdown(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), io::Error>> {
4746
self.project().unix_stream.poll_shutdown(cx)
4847
}
@@ -80,16 +79,20 @@ impl Unpin for UnixConnector {}
8079

8180
impl Service<Uri> for UnixConnector {
8281
type Response = UnixStream;
83-
type Error = std::io::Error;
84-
type Future = Pin<Box<dyn Future<Output = Result<Self::Response, Self::Error>> + Send + 'static>>;
82+
type Error = io::Error;
83+
#[allow(clippy::type_complexity)]
84+
type Future =
85+
Pin<Box<dyn Future<Output = Result<Self::Response, Self::Error>> + Send + 'static>>;
86+
8587
fn call(&mut self, req: Uri) -> Self::Future {
8688
let fut = async move {
87-
let path = parse_socket_path(req)?;
89+
let path = parse_socket_path(&req)?;
8890
UnixStream::connect(path).await
8991
};
9092

9193
Box::pin(fut)
9294
}
95+
9396
fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
9497
Poll::Ready(Ok(()))
9598
}
@@ -101,7 +104,7 @@ impl Connection for UnixStream {
101104
}
102105
}
103106

104-
fn parse_socket_path(uri: Uri) -> Result<std::path::PathBuf, io::Error> {
107+
fn parse_socket_path(uri: &Uri) -> Result<PathBuf, io::Error> {
105108
if uri.scheme_str() != Some("unix") {
106109
return Err(io::Error::new(
107110
io::ErrorKind::InvalidInput,
@@ -138,6 +141,7 @@ pub trait UnixClientExt {
138141
///
139142
/// let client = Client::unix();
140143
/// ```
144+
#[must_use]
141145
fn unix() -> Client<UnixConnector, Body> {
142146
Client::builder().build(UnixConnector)
143147
}

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
rust_2018_idioms,
55
missing_docs
66
)]
7+
#![warn(clippy::all, clippy::pedantic)]
78

89
//! `hyperlocal` provides [Hyper](http://github.com/hyperium/hyper) bindings
910
//! for [Unix domain sockets](https://github.com/tokio-rs/tokio/tree/master/tokio-net/src/uds/).

src/server.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ pub(crate) mod conn {
2525

2626
impl SocketIncoming {
2727
/// Creates a new `SocketIncoming` binding to provided socket path.
28+
///
29+
/// # Errors
30+
/// Refer to [`tokio::net::Listener::bind`](https://docs.rs/tokio/1.15.0/tokio/net/struct.UnixListener.html#method.bind).
2831
pub fn bind(path: impl AsRef<Path>) -> Result<Self, std::io::Error> {
2932
let listener = UnixListener::bind(path)?;
3033

@@ -50,7 +53,8 @@ pub(crate) mod conn {
5053
self: Pin<&mut Self>,
5154
cx: &mut Context<'_>,
5255
) -> Poll<Option<Result<Self::Conn, Self::Error>>> {
53-
self.listener.poll_accept(cx)?
56+
self.listener
57+
.poll_accept(cx)?
5458
.map(|(conn, _)| Some(Ok(conn)))
5559
}
5660
}
@@ -84,6 +88,7 @@ pub(crate) mod conn {
8488
/// ```
8589
pub trait UnixServerExt {
8690
/// Convenience method for constructing a Server listening on a Unix socket.
91+
#[allow(clippy::missing_errors_doc)]
8792
fn bind_unix(path: impl AsRef<Path>) -> Result<Builder<SocketIncoming>, io::Error>;
8893
}
8994

src/uri.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ pub struct Uri {
1919

2020
impl Uri {
2121
/// Create a new `[Uri]` from a socket address and a path
22+
///
23+
/// # Panics
24+
/// Will panic if path is not absolute and/or a malformed path string.
2225
pub fn new(socket: impl AsRef<Path>, path: &str) -> Self {
2326
let host = hex::encode(socket.as_ref().to_string_lossy().as_bytes());
2427
let host_str = format!("unix://{}:0{}", host, path);

0 commit comments

Comments
 (0)