Skip to content

Commit

Permalink
Add ability to create a new WebPushClient from a custom Isahc/hyper c…
Browse files Browse the repository at this point in the history
…lient (#56) (#57)

* Add ability to create a new WebPushClient from a custom Isahc/hyper client (#56)

* Apply clippy fixes
  • Loading branch information
naskya authored May 3, 2024
1 parent 010cac3 commit 40febe4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/clients/hyper_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ impl Default for HyperWebPushClient {
}
}

impl From<Client<HttpsConnector<HttpConnector>>> for HyperWebPushClient {
/// Creates a new client from a custom hyper HTTP client.
fn from(client: Client<HttpsConnector<HttpConnector>>) -> Self {
Self { client }
}
}

impl HyperWebPushClient {
/// Creates a new client.
pub fn new() -> Self {
Expand Down
7 changes: 7 additions & 0 deletions src/clients/isahc_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ impl Default for IsahcWebPushClient {
}
}

impl From<HttpClient> 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<Self, WebPushError> {
Expand Down
2 changes: 1 addition & 1 deletion src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 == '_')
}
1 change: 0 additions & 1 deletion src/vapid/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 40febe4

Please sign in to comment.