From 40febe4085e3cef9cdfd539c315e3e945aba0656 Mon Sep 17 00:00:00 2001 From: naskya Date: Fri, 3 May 2024 14:02:00 +0900 Subject: [PATCH] Add ability to create a new WebPushClient from a custom Isahc/hyper client (#56) (#57) * Add ability to create a new WebPushClient from a custom Isahc/hyper client (#56) * Apply clippy fixes --- src/clients/hyper_client.rs | 7 +++++++ src/clients/isahc_client.rs | 7 +++++++ src/message.rs | 2 +- src/vapid/mod.rs | 1 - 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/clients/hyper_client.rs b/src/clients/hyper_client.rs index dfdd16c1..3f4c0fd7 100644 --- a/src/clients/hyper_client.rs +++ b/src/clients/hyper_client.rs @@ -25,6 +25,13 @@ impl Default for HyperWebPushClient { } } +impl From>> for HyperWebPushClient { + /// Creates a new client from a custom hyper HTTP client. + fn from(client: Client>) -> Self { + Self { client } + } +} + impl HyperWebPushClient { /// Creates a new client. pub fn new() -> Self { diff --git a/src/clients/isahc_client.rs b/src/clients/isahc_client.rs index d4c67947..5b8dec2b 100644 --- a/src/clients/isahc_client.rs +++ b/src/clients/isahc_client.rs @@ -26,6 +26,13 @@ impl Default for IsahcWebPushClient { } } +impl From for IsahcWebPushClient { + /// Creates a new client from a custom Isahc HTTP client. + fn from(client: HttpClient) -> Self { + Self { client } + } +} + impl IsahcWebPushClient { /// Creates a new client. Can fail under resource depletion. pub fn new() -> Result { diff --git a/src/message.rs b/src/message.rs index bff20d49..8a1ff419 100644 --- a/src/message.rs +++ b/src/message.rs @@ -208,5 +208,5 @@ impl<'a> WebPushMessageBuilder<'a> { } fn is_base64url_char(c: char) -> bool { - return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || (c == '-' || c == '_'); + c.is_ascii_uppercase() || c.is_ascii_lowercase() || c.is_ascii_digit() || (c == '-' || c == '_') } diff --git a/src/vapid/mod.rs b/src/vapid/mod.rs index b8366d59..9fbf7d72 100644 --- a/src/vapid/mod.rs +++ b/src/vapid/mod.rs @@ -2,7 +2,6 @@ pub use self::builder::VapidSignatureBuilder; use self::key::VapidKey; -pub use self::signer::Claims; pub use self::signer::VapidSignature; use self::signer::VapidSigner;