diff --git a/crates/gpui/src/app.rs b/crates/gpui/src/app.rs index 864968b9e7a9ad862d9b67a19cc8897524dffb9e..9d93de53d06f3130f28b39c7b21611f7996abf89 100644 --- a/crates/gpui/src/app.rs +++ b/crates/gpui/src/app.rs @@ -2400,10 +2400,6 @@ impl HttpClient for NullHttpClient { fn proxy(&self) -> Option<&Url> { None } - - fn type_name(&self) -> &'static str { - type_name::() - } } /// A mutable reference to an entity owned by GPUI diff --git a/crates/http_client/src/http_client.rs b/crates/http_client/src/http_client.rs index a75df61646f31c9dc997bea83acc9d669bf1e29e..98c67f4e27a8e8b20489cc3c4ad4a1207e8b848f 100644 --- a/crates/http_client/src/http_client.rs +++ b/crates/http_client/src/http_client.rs @@ -14,9 +14,9 @@ use futures::{ }; use parking_lot::Mutex; use serde::Serialize; +use std::sync::Arc; #[cfg(feature = "test-support")] -use std::fmt; -use std::{any::type_name, sync::Arc}; +use std::{any::type_name, fmt}; pub use url::{Host, Url}; #[derive(Default, Debug, Clone, PartialEq, Eq, Hash)] @@ -59,10 +59,10 @@ impl HttpRequestExt for http::request::Builder { } pub trait HttpClient: 'static + Send + Sync { - fn type_name(&self) -> &'static str; - fn user_agent(&self) -> Option<&HeaderValue>; + fn proxy(&self) -> Option<&Url>; + fn send( &self, req: http::Request, @@ -106,8 +106,6 @@ pub trait HttpClient: 'static + Send + Sync { } } - fn proxy(&self) -> Option<&Url>; - #[cfg(feature = "test-support")] fn as_fake(&self) -> &FakeHttpClient { panic!("called as_fake on {}", type_name::()) @@ -163,10 +161,6 @@ impl HttpClient for HttpClientWithProxy { self.proxy.as_ref() } - fn type_name(&self) -> &'static str { - self.client.type_name() - } - #[cfg(feature = "test-support")] fn as_fake(&self) -> &FakeHttpClient { self.client.as_fake() @@ -182,19 +176,13 @@ impl HttpClient for HttpClientWithProxy { } /// An [`HttpClient`] that has a base URL. +#[derive(Deref)] pub struct HttpClientWithUrl { base_url: Mutex, + #[deref] client: HttpClientWithProxy, } -impl std::ops::Deref for HttpClientWithUrl { - type Target = HttpClientWithProxy; - - fn deref(&self) -> &Self::Target { - &self.client - } -} - impl HttpClientWithUrl { /// Returns a new [`HttpClientWithUrl`] with the given base URL. pub fn new( @@ -314,10 +302,6 @@ impl HttpClient for HttpClientWithUrl { self.client.proxy.as_ref() } - fn type_name(&self) -> &'static str { - self.client.type_name() - } - #[cfg(feature = "test-support")] fn as_fake(&self) -> &FakeHttpClient { self.client.as_fake() @@ -384,10 +368,6 @@ impl HttpClient for BlockedHttpClient { None } - fn type_name(&self) -> &'static str { - type_name::() - } - #[cfg(feature = "test-support")] fn as_fake(&self) -> &FakeHttpClient { panic!("called as_fake on {}", type_name::()) @@ -482,10 +462,6 @@ impl HttpClient for FakeHttpClient { None } - fn type_name(&self) -> &'static str { - type_name::() - } - fn as_fake(&self) -> &FakeHttpClient { self } diff --git a/crates/reqwest_client/src/reqwest_client.rs b/crates/reqwest_client/src/reqwest_client.rs index d0d25bdf258e12a28bef1f29e608532075bbed7b..c2a58877b32ab6049edc5b50f7ad025f0c83f46e 100644 --- a/crates/reqwest_client/src/reqwest_client.rs +++ b/crates/reqwest_client/src/reqwest_client.rs @@ -1,6 +1,6 @@ use std::error::Error; use std::sync::{LazyLock, OnceLock}; -use std::{any::type_name, borrow::Cow, mem, pin::Pin, task::Poll, time::Duration}; +use std::{borrow::Cow, mem, pin::Pin, task::Poll, time::Duration}; use anyhow::anyhow; use bytes::{BufMut, Bytes, BytesMut}; @@ -215,10 +215,6 @@ impl http_client::HttpClient for ReqwestClient { self.proxy.as_ref() } - fn type_name(&self) -> &'static str { - type_name::() - } - fn user_agent(&self) -> Option<&HeaderValue> { self.user_agent.as_ref() }