Skip to content

Commit 3eba2dd

Browse files
committed
Impl Clone for both clients.
Also bump Rust version to 2021.
1 parent 475fc40 commit 3eba2dd

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "web-push"
33
description = "Web push notification client with support for http-ece encryption and VAPID authentication."
4-
version = "0.9.1"
4+
version = "0.9.2"
55
authors = ["Julius de Bruijn <[email protected]>", "Andrew Ealovega <[email protected]>"]
66
license = "Apache-2.0"
77
homepage = "https://github.com/pimeys/rust-web-push"
@@ -10,7 +10,7 @@ documentation = "https://docs.rs/web-push/"
1010
readme = "README.md"
1111
keywords = ["web-push", "http-ece", "vapid"]
1212
categories = ["web-programming", "asynchronous"]
13-
edition = "2018"
13+
edition = "2021"
1414

1515
[features]
1616
default = ["isahc", "futures-lite/futures-io"] #futures are only used for read_to_end() in isach client.

rustfmt.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
max_width = 120
2-
edition = "2018"
2+
edition = "2021"

src/clients/hyper_client.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ use crate::message::WebPushMessage;
1010

1111
/// An async client for sending the notification payload.
1212
///
13+
/// This client is thread-safe. Clones of this client will share the same underlying resources,
14+
/// so cloning is a cheap and effective method to provide access to the client.
15+
///
1316
/// This client is [`hyper`](https://crates.io/crates/hyper) based, and will only work in Tokio contexts.
17+
#[derive(Clone)]
1418
pub struct WebPushClient {
1519
client: Client<HttpsConnector<HttpConnector>>,
1620
}
@@ -48,7 +52,7 @@ impl WebPushClient {
4852
.headers()
4953
.get(RETRY_AFTER)
5054
.and_then(|ra| ra.to_str().ok())
51-
.and_then(|ra| RetryAfter::from_str(ra));
55+
.and_then(RetryAfter::from_str);
5256

5357
let response_status = response.status();
5458
trace!("Response status: {}", response_status);

src/clients/isahc_client.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ use crate::message::WebPushMessage;
99
/// An async client for sending the notification payload. This client is expensive to create, and
1010
/// should be reused.
1111
///
12+
/// This client is thread-safe. Clones of this client will share the same underlying resources,
13+
/// so cloning is a cheap and effective method to provide access to the client.
14+
///
1215
/// This client is built on [`isahc`](https://crates.io/crates/isahc), and will therefore work on any async executor.
16+
#[derive(Clone)]
1317
pub struct WebPushClient {
1418
client: HttpClient,
1519
}
@@ -46,7 +50,7 @@ impl WebPushClient {
4650
.headers()
4751
.get(RETRY_AFTER)
4852
.and_then(|ra| ra.to_str().ok())
49-
.and_then(|ra| RetryAfter::from_str(ra));
53+
.and_then(RetryAfter::from_str);
5054

5155
let response_status = response.status();
5256
trace!("Response status: {}", response_status);

0 commit comments

Comments
 (0)