| @@ -25,9 +25,6 @@ use crate::{ · 24 unmodified lines |
| 25 | Protocol, Service, | 25 | Protocol, Service, |
| 26 | }; | 26 | }; |
| 27 | | 27 | |
| 28 | #[cfg(all(feature = "http-client-reqwest", feature = "http-client-curl"))] | | |
| 29 | compile_error!("Cannot set both 'http-client-reqwest' and 'http-client-curl' features as they are mutually exclusive"); | | |
| 30 | | | |
| 31 | #[cfg(feature = "http-client-curl")] | 28 | #[cfg(feature = "http-client-curl")] |
| 32 | /// | 29 | /// |
| 33 | pub mod curl; | 30 | pub mod curl; |
| @@ -215,13 +212,6 @@ impl Default for Options { · 181 unmodified lines |
| 215 | } | 212 | } |
| 216 | } | 213 | } |
| 217 | | 214 | |
| 218 | /// The actual http client implementation, using curl | | |
| 219 | #[cfg(feature = "http-client-curl")] | | |
| 220 | pub type Impl = curl::Curl; | | |
| 221 | /// The actual http client implementation, using reqwest | | |
| 222 | #[cfg(feature = "http-client-reqwest")] | | |
| 223 | pub type Impl = reqwest::Remote; | | |
| 224 | | | |
| 225 | /// A transport for supporting arbitrary http clients by abstracting interactions with them into the [Http] trait. | 215 | /// A transport for supporting arbitrary http clients by abstracting interactions with them into the [Http] trait. |
| 226 | pub struct Transport<H: Http> { | 216 | pub struct Transport<H: Http> { |
| 227 | url: String, | 217 | url: String, |
| @@ -270,13 +260,13 @@ impl<H: Http> Transport<H> { · 42 unmodified lines |
| 270 | } | 260 | } |
| 271 | | 261 | |
| 272 | #[cfg(any(feature = "http-client-curl", feature = "http-client-reqwest"))] | 262 | #[cfg(any(feature = "http-client-curl", feature = "http-client-reqwest"))] |
| 273 | impl Transport<Impl> { | 263 | impl<H: Http + Default> Transport<H> { |
| 274 | /// Create a new instance to communicate to `url` using the given `desired_version` of the `git` protocol. | 264 | /// Create a new instance to communicate to `url` using the given `desired_version` of the `git` protocol. |
| 275 | /// If `trace` is `true`, all packetlines received or sent will be passed to the facilities of the `gix-trace` crate. | 265 | /// If `trace` is `true`, all packetlines received or sent will be passed to the facilities of the `gix-trace` crate. |
| 276 | /// | 266 | /// |
| 277 | /// Note that the actual implementation depends on feature toggles. | 267 | /// Note that the actual implementation depends on feature toggles. |
| 278 | pub fn new(url: gix_url::Url, desired_version: Protocol, trace: bool) -> Self { | 268 | pub fn new(url: gix_url::Url, desired_version: Protocol, trace: bool) -> Self { |
| 279 | Self::new_http(Impl::default(), url, desired_version, trace) | 269 | Self::new_http(H::default(), url, desired_version, trace) |
| 280 | } | 270 | } |
| 281 | } | 271 | } |
| 282 | | 272 | |
| @@ -555,7 +545,7 @@ pub fn connect_http<H: Http>(http: H, url: gix_url::Url, desired_version: Protoc · 272 unmodified lines |
| 555 | /// Connect to the given `url` via HTTP/S using the `desired_version` of the `git` protocol. | 545 | /// Connect to the given `url` via HTTP/S using the `desired_version` of the `git` protocol. |
| 556 | /// If `trace` is `true`, all packetlines received or sent will be passed to the facilities of the `gix-trace` crate. | 546 | /// If `trace` is `true`, all packetlines received or sent will be passed to the facilities of the `gix-trace` crate. |
| 557 | #[cfg(any(feature = "http-client-curl", feature = "http-client-reqwest"))] | 547 | #[cfg(any(feature = "http-client-curl", feature = "http-client-reqwest"))] |
| 558 | pub fn connect(url: gix_url::Url, desired_version: Protocol, trace: bool) -> Transport<Impl> { | 548 | pub fn connect<H: Http + Default>(url: gix_url::Url, desired_version: Protocol, trace: bool) -> Transport<H> { |
| 559 | Transport::new(url, desired_version, trace) | 549 | Transport::new(url, desired_version, trace) |
| 560 | } | 550 | } |
| 561 | | 551 | |