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)
  • Loading branch information
naskya committed Apr 29, 2024
1 parent 010cac3 commit cf20889
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 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

0 comments on commit cf20889

Please sign in to comment.