From cf20889a6343acc66e61e4f72faa5e9d7dec42b7 Mon Sep 17 00:00:00 2001 From: naskya Date: Mon, 29 Apr 2024 18:17:18 +0900 Subject: [PATCH] Add ability to create a new WebPushClient from a custom Isahc/hyper client (#56) --- src/clients/hyper_client.rs | 7 +++++++ src/clients/isahc_client.rs | 7 +++++++ 2 files changed, 14 insertions(+) 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 {