From 0fa686ac1d76a28471b9478947ee54d7d822c907 Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Wed, 28 Apr 2021 02:07:43 +0200 Subject: [PATCH] client: Add a dummy http client --- ruma-client/src/http_client.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/ruma-client/src/http_client.rs b/ruma-client/src/http_client.rs index ffaca64b..6dc3765f 100644 --- a/ruma-client/src/http_client.rs +++ b/ruma-client/src/http_client.rs @@ -90,3 +90,27 @@ pub trait HttpClientExt: HttpClient { #[async_trait] impl HttpClientExt for T {} + +#[doc(hidden)] +#[derive(Debug)] +pub struct Dummy; + +#[async_trait] +impl HttpClient for Dummy { + type RequestBody = Vec; + type ResponseBody = Vec; + type Error = (); + + async fn send_http_request( + &self, + _req: http::Request, + ) -> Result, Self::Error> { + unimplemented!("this client only exists to allow doctests to compile") + } +} + +impl DefaultConstructibleHttpClient for Dummy { + fn default() -> Self { + Dummy + } +}