Skip to content

Commit

Permalink
Impl Clone for both clients.
Browse files Browse the repository at this point in the history
Also bump Rust version to 2021.
  • Loading branch information
andyblarblar committed Apr 2, 2022
1 parent 475fc40 commit 3eba2dd
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "web-push"
description = "Web push notification client with support for http-ece encryption and VAPID authentication."
version = "0.9.1"
version = "0.9.2"
authors = ["Julius de Bruijn <[email protected]>", "Andrew Ealovega <[email protected]>"]
license = "Apache-2.0"
homepage = "https://github.com/pimeys/rust-web-push"
Expand All @@ -10,7 +10,7 @@ documentation = "https://docs.rs/web-push/"
readme = "README.md"
keywords = ["web-push", "http-ece", "vapid"]
categories = ["web-programming", "asynchronous"]
edition = "2018"
edition = "2021"

[features]
default = ["isahc", "futures-lite/futures-io"] #futures are only used for read_to_end() in isach client.
Expand Down
2 changes: 1 addition & 1 deletion rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
max_width = 120
edition = "2018"
edition = "2021"
6 changes: 5 additions & 1 deletion src/clients/hyper_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ use crate::message::WebPushMessage;

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

let response_status = response.status();
trace!("Response status: {}", response_status);
Expand Down
6 changes: 5 additions & 1 deletion src/clients/isahc_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ use crate::message::WebPushMessage;
/// An async client for sending the notification payload. This client is expensive to create, and
/// should be reused.
///
/// This client is thread-safe. Clones of this client will share the same underlying resources,
/// so cloning is a cheap and effective method to provide access to the client.
///
/// This client is built on [`isahc`](https://crates.io/crates/isahc), and will therefore work on any async executor.
#[derive(Clone)]
pub struct WebPushClient {
client: HttpClient,
}
Expand Down Expand Up @@ -46,7 +50,7 @@ impl WebPushClient {
.headers()
.get(RETRY_AFTER)
.and_then(|ra| ra.to_str().ok())
.and_then(|ra| RetryAfter::from_str(ra));
.and_then(RetryAfter::from_str);

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

0 comments on commit 3eba2dd

Please sign in to comment.