diff --git a/gix-transport/src/client/blocking_io/connect.rs b/gix-transport/src/client/blocking_io/connect.rs index c982805568e..ba9519d4b27 100644 --- a/gix-transport/src/client/blocking_io/connect.rs +++ b/gix-transport/src/client/blocking_io/connect.rs @@ -1,6 +1,10 @@ pub use crate::client::non_io_types::connect::{Error, Options}; pub(crate) mod function { + #[cfg(feature = "http-client-curl")] + use crate::client::blocking_io::http::curl::Curl; + #[cfg(feature = "http-client-reqwest")] + use crate::client::blocking_io::http::reqwest::Remote as Reqwest; use crate::client::{blocking_io::Transport, non_io_types::connect::Error}; /// A general purpose connector connecting to a repository identified by the given `url`. @@ -57,11 +61,15 @@ pub(crate) mod function { } #[cfg(not(any(feature = "http-client-curl", feature = "http-client-reqwest")))] gix_url::Scheme::Https | gix_url::Scheme::Http => return Err(Error::CompiledWithoutHttp(url.scheme)), - #[cfg(any(feature = "http-client-curl", feature = "http-client-reqwest"))] - gix_url::Scheme::Https | gix_url::Scheme::Http => Box::new(crate::client::blocking_io::http::connect( - url, - options.version, - options.trace, + #[cfg(feature = "http-client-curl")] + gix_url::Scheme::Https | gix_url::Scheme::Http => Box::new( + crate::client::blocking_io::http::connect::(url, options.version, options.trace), + ), + #[cfg(all(feature = "http-client-reqwest", not(feature = "http-client-curl")))] + gix_url::Scheme::Https | gix_url::Scheme::Http => Box::new(crate::client::blocking_io::http::connect::< + Reqwest, + >( + url, options.version, options.trace )), }) } diff --git a/gix-transport/src/client/blocking_io/http/mod.rs b/gix-transport/src/client/blocking_io/http/mod.rs index 154aa89fd4a..8b6b90e57d9 100644 --- a/gix-transport/src/client/blocking_io/http/mod.rs +++ b/gix-transport/src/client/blocking_io/http/mod.rs @@ -25,9 +25,6 @@ use crate::{ Protocol, Service, }; -#[cfg(all(feature = "http-client-reqwest", feature = "http-client-curl"))] -compile_error!("Cannot set both 'http-client-reqwest' and 'http-client-curl' features as they are mutually exclusive"); - #[cfg(feature = "http-client-curl")] /// pub mod curl; @@ -215,13 +212,6 @@ impl Default for Options { } } -/// The actual http client implementation, using curl -#[cfg(feature = "http-client-curl")] -pub type Impl = curl::Curl; -/// The actual http client implementation, using reqwest -#[cfg(feature = "http-client-reqwest")] -pub type Impl = reqwest::Remote; - /// A transport for supporting arbitrary http clients by abstracting interactions with them into the [Http] trait. pub struct Transport { url: String, @@ -270,13 +260,13 @@ impl Transport { } #[cfg(any(feature = "http-client-curl", feature = "http-client-reqwest"))] -impl Transport { +impl Transport { /// Create a new instance to communicate to `url` using the given `desired_version` of the `git` protocol. /// If `trace` is `true`, all packetlines received or sent will be passed to the facilities of the `gix-trace` crate. /// /// Note that the actual implementation depends on feature toggles. pub fn new(url: gix_url::Url, desired_version: Protocol, trace: bool) -> Self { - Self::new_http(Impl::default(), url, desired_version, trace) + Self::new_http(H::default(), url, desired_version, trace) } } @@ -555,7 +545,7 @@ pub fn connect_http(http: H, url: gix_url::Url, desired_version: Protoc /// Connect to the given `url` via HTTP/S using the `desired_version` of the `git` protocol. /// If `trace` is `true`, all packetlines received or sent will be passed to the facilities of the `gix-trace` crate. #[cfg(any(feature = "http-client-curl", feature = "http-client-reqwest"))] -pub fn connect(url: gix_url::Url, desired_version: Protocol, trace: bool) -> Transport { +pub fn connect(url: gix_url::Url, desired_version: Protocol, trace: bool) -> Transport { Transport::new(url, desired_version, trace) }