Skip to content

Commit 1aecd5a

Browse files
authored
Merge pull request #18 from hjr3/actions
Replace Travis CI with GitHub Actions
2 parents 1766cd6 + 3e665b6 commit 1aecd5a

File tree

7 files changed

+80
-29
lines changed

7 files changed

+80
-29
lines changed

.github/workflows/ci.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
on:
2+
push:
3+
branches:
4+
- master
5+
pull_request: {}
6+
7+
name: Continuous integration
8+
9+
jobs:
10+
check:
11+
name: Check
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
- uses: actions-rs/toolchain@v1
16+
with:
17+
profile: minimal
18+
toolchain: stable
19+
override: true
20+
- uses: actions-rs/cargo@v1
21+
with:
22+
command: check
23+
24+
test:
25+
name: Test Suite
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@v2
29+
- uses: actions-rs/toolchain@v1
30+
with:
31+
profile: minimal
32+
toolchain: stable
33+
override: true
34+
- uses: actions-rs/cargo@v1
35+
with:
36+
command: test
37+
38+
fmt:
39+
name: Rustfmt
40+
runs-on: ubuntu-latest
41+
steps:
42+
- uses: actions/checkout@v2
43+
- uses: actions-rs/toolchain@v1
44+
with:
45+
profile: minimal
46+
toolchain: stable
47+
override: true
48+
- run: rustup component add rustfmt
49+
- uses: actions-rs/cargo@v1
50+
with:
51+
command: fmt
52+
args: --all -- --check
53+
54+
clippy:
55+
name: Clippy
56+
runs-on: ubuntu-latest
57+
steps:
58+
- uses: actions/checkout@v2
59+
- uses: actions-rs/toolchain@v1
60+
with:
61+
profile: minimal
62+
toolchain: stable
63+
override: true
64+
- run: rustup component add clippy
65+
- uses: actions-rs/cargo@v1
66+
with:
67+
command: clippy
68+
args: -- -D warnings

.travis.yml

Lines changed: 0 additions & 14 deletions
This file was deleted.

Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ homepage = "https://github.com/hjr3/hyper-timeout"
1010
repository = "https://github.com/hjr3/hyper-timeout"
1111
readme = "README.md"
1212

13-
[badges]
14-
travis-ci = { repository = "https://github.com/hjr3/hyper-timeout", branch = "master" }
15-
1613
[dependencies]
1714
bytes = "1.0.0"
1815
hyper = { version = "0.14", default-features = false, features = ["client", "http1", "tcp"] }

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
[![Build Status](https://travis-ci.org/hjr3/hyper-timeout.svg?branch=master)](https://travis-ci.org/hjr3/hyper-timeout)
21
[![crates.io](https://img.shields.io/crates/v/hyper-timeout.svg)](https://crates.io/crates/hyper-timeout)
32

43
# hyper-timeout

examples/client.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::env;
22
use std::time::Duration;
33

4-
use hyper::{Client, body::HttpBody as _};
4+
use hyper::{body::HttpBody as _, Client};
55
use tokio::io::{self, AsyncWriteExt as _};
66

77
use hyper::client::HttpConnector;
@@ -38,9 +38,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
3838

3939
while let Some(chunk) = res.body_mut().data().await {
4040
let chunk = chunk?;
41-
io::stdout()
42-
.write_all(&chunk)
43-
.await?
41+
io::stdout().write_all(&chunk).await?
4442
}
4543
Ok(())
4644
}

src/lib.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ use tokio::io::{AsyncRead, AsyncWrite};
77
use tokio::time::{timeout, Duration};
88
use tokio_io_timeout::TimeoutStream;
99

10-
use hyper::{service::Service, Uri};
1110
use hyper::client::connect::{Connect, Connected, Connection};
11+
use hyper::{service::Service, Uri};
1212

1313
mod stream;
1414

@@ -33,7 +33,7 @@ impl<T: Connect> TimeoutConnector<T> {
3333
/// Construct a new TimeoutConnector with a given connector implementing the `Connect` trait
3434
pub fn new(connector: T) -> Self {
3535
TimeoutConnector {
36-
connector: connector,
36+
connector,
3737
connect_timeout: None,
3838
read_timeout: None,
3939
write_timeout: None,
@@ -50,15 +50,16 @@ where
5050
{
5151
type Response = Pin<Box<TimeoutConnectorStream<T::Response>>>;
5252
type Error = BoxError;
53+
#[allow(clippy::type_complexity)]
5354
type Future = Pin<Box<dyn Future<Output = Result<Self::Response, Self::Error>> + Send>>;
5455

5556
fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
5657
self.connector.poll_ready(cx).map_err(Into::into)
5758
}
5859

5960
fn call(&mut self, dst: Uri) -> Self::Future {
60-
let read_timeout = self.read_timeout.clone();
61-
let write_timeout = self.write_timeout.clone();
61+
let read_timeout = self.read_timeout;
62+
let write_timeout = self.write_timeout;
6263
let connecting = self.connector.call(dst);
6364

6465
if self.connect_timeout.is_none() {
@@ -78,7 +79,9 @@ where
7879
let timeout = timeout(connect_timeout, connecting);
7980

8081
let fut = async move {
81-
let connecting = timeout.await.map_err(|e| io::Error::new(io::ErrorKind::TimedOut, e))?;
82+
let connecting = timeout
83+
.await
84+
.map_err(|e| io::Error::new(io::ErrorKind::TimedOut, e))?;
8285
let io = connecting.map_err(Into::into)?;
8386

8487
let mut tm = TimeoutConnectorStream::new(TimeoutStream::new(io));
@@ -132,8 +135,8 @@ mod tests {
132135
use std::io;
133136
use std::time::Duration;
134137

135-
use hyper::Client;
136138
use hyper::client::HttpConnector;
139+
use hyper::Client;
137140

138141
use super::TimeoutConnector;
139142

src/stream.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::io;
22
use std::io::IoSlice;
33
use std::pin::Pin;
44
use std::task::{Context, Poll};
5-
use std::time::{Duration};
5+
use std::time::Duration;
66

77
use hyper::client::connect::{Connected, Connection};
88
use pin_project_lite::pin_project;

0 commit comments

Comments
 (0)