diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..bf58ec8 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,68 @@ +on: + push: + branches: + - master + pull_request: {} + +name: Continuous integration + +jobs: + check: + name: Check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - uses: actions-rs/cargo@v1 + with: + command: check + + test: + name: Test Suite + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - uses: actions-rs/cargo@v1 + with: + command: test + + fmt: + name: Rustfmt + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - run: rustup component add rustfmt + - uses: actions-rs/cargo@v1 + with: + command: fmt + args: --all -- --check + + clippy: + name: Clippy + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - run: rustup component add clippy + - uses: actions-rs/cargo@v1 + with: + command: clippy + args: -- -D warnings diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 574a0b5..0000000 --- a/.travis.yml +++ /dev/null @@ -1,14 +0,0 @@ -language: rust -sudo: false - -rust: - - nightly - - beta - - stable - -matrix: - allow_failures: - - rust: nightly - -cache: - cargo: true diff --git a/Cargo.toml b/Cargo.toml index d0977a0..f898bd0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,9 +10,6 @@ homepage = "https://github.com/hjr3/hyper-timeout" repository = "https://github.com/hjr3/hyper-timeout" readme = "README.md" -[badges] -travis-ci = { repository = "https://github.com/hjr3/hyper-timeout", branch = "master" } - [dependencies] bytes = "1.0.0" hyper = { version = "0.14", default-features = false, features = ["client", "http1", "tcp"] } diff --git a/README.md b/README.md index 3b6b479..6c34c76 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,3 @@ -[![Build Status](https://travis-ci.org/hjr3/hyper-timeout.svg?branch=master)](https://travis-ci.org/hjr3/hyper-timeout) [![crates.io](https://img.shields.io/crates/v/hyper-timeout.svg)](https://crates.io/crates/hyper-timeout) # hyper-timeout diff --git a/examples/client.rs b/examples/client.rs index fb6182f..da9497f 100644 --- a/examples/client.rs +++ b/examples/client.rs @@ -1,7 +1,7 @@ use std::env; use std::time::Duration; -use hyper::{Client, body::HttpBody as _}; +use hyper::{body::HttpBody as _, Client}; use tokio::io::{self, AsyncWriteExt as _}; use hyper::client::HttpConnector; @@ -38,9 +38,7 @@ async fn main() -> Result<(), Box> { while let Some(chunk) = res.body_mut().data().await { let chunk = chunk?; - io::stdout() - .write_all(&chunk) - .await? + io::stdout().write_all(&chunk).await? } Ok(()) } diff --git a/src/lib.rs b/src/lib.rs index c93117b..455228a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,8 +7,8 @@ use tokio::io::{AsyncRead, AsyncWrite}; use tokio::time::{timeout, Duration}; use tokio_io_timeout::TimeoutStream; -use hyper::{service::Service, Uri}; use hyper::client::connect::{Connect, Connected, Connection}; +use hyper::{service::Service, Uri}; mod stream; @@ -33,7 +33,7 @@ impl TimeoutConnector { /// Construct a new TimeoutConnector with a given connector implementing the `Connect` trait pub fn new(connector: T) -> Self { TimeoutConnector { - connector: connector, + connector, connect_timeout: None, read_timeout: None, write_timeout: None, @@ -50,6 +50,7 @@ where { type Response = Pin>>; type Error = BoxError; + #[allow(clippy::type_complexity)] type Future = Pin> + Send>>; fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { @@ -57,8 +58,8 @@ where } fn call(&mut self, dst: Uri) -> Self::Future { - let read_timeout = self.read_timeout.clone(); - let write_timeout = self.write_timeout.clone(); + let read_timeout = self.read_timeout; + let write_timeout = self.write_timeout; let connecting = self.connector.call(dst); if self.connect_timeout.is_none() { @@ -78,7 +79,9 @@ where let timeout = timeout(connect_timeout, connecting); let fut = async move { - let connecting = timeout.await.map_err(|e| io::Error::new(io::ErrorKind::TimedOut, e))?; + let connecting = timeout + .await + .map_err(|e| io::Error::new(io::ErrorKind::TimedOut, e))?; let io = connecting.map_err(Into::into)?; let mut tm = TimeoutConnectorStream::new(TimeoutStream::new(io)); @@ -132,8 +135,8 @@ mod tests { use std::io; use std::time::Duration; - use hyper::Client; use hyper::client::HttpConnector; + use hyper::Client; use super::TimeoutConnector; diff --git a/src/stream.rs b/src/stream.rs index ac2287e..2c0ab65 100644 --- a/src/stream.rs +++ b/src/stream.rs @@ -2,7 +2,7 @@ use std::io; use std::io::IoSlice; use std::pin::Pin; use std::task::{Context, Poll}; -use std::time::{Duration}; +use std::time::Duration; use hyper::client::connect::{Connected, Connection}; use pin_project_lite::pin_project;