diff --git a/Cargo.toml b/Cargo.toml index bff4600a..29484afe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 ", "Andrew Ealovega "] license = "Apache-2.0" homepage = "https://github.com/pimeys/rust-web-push" @@ -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. diff --git a/rustfmt.toml b/rustfmt.toml index 9328e6c1..01b441c0 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,2 +1,2 @@ max_width = 120 -edition = "2018" +edition = "2021" diff --git a/src/clients/hyper_client.rs b/src/clients/hyper_client.rs index 5490b001..a427f015 100644 --- a/src/clients/hyper_client.rs +++ b/src/clients/hyper_client.rs @@ -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>, } @@ -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); diff --git a/src/clients/isahc_client.rs b/src/clients/isahc_client.rs index cf494fad..467921de 100644 --- a/src/clients/isahc_client.rs +++ b/src/clients/isahc_client.rs @@ -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, } @@ -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);