Skip to content

Commit ae65278

Browse files
committed
refactor
1 parent 87d5419 commit ae65278

File tree

6 files changed

+35
-31
lines changed

6 files changed

+35
-31
lines changed

gix-transport/Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ doctest = false
1818
default = []
1919

2020
## If set, blocking implementations of the typical git transports become available in `crate::client::blocking_io`
21+
##
22+
## If used in conjunction with an async implementation, this one takes precedence.
2123
blocking-client = ["gix-packetline/blocking-io"]
2224
## Implies `blocking-client`, and adds support for the http and https transports.
2325
http-client = [
@@ -27,10 +29,12 @@ http-client = [
2729
"gix-credentials",
2830
]
2931
## Implies `http-client`, and adds support for the http and https transports using the Rust bindings for `libcurl`.
32+
##
33+
## If used in conjunction with other blocking implementations like `http-client-reqwest`, this one takes precedence.
3034
http-client-curl = ["curl", "http-client"]
3135
## Implies `http-client-curl` and enables `rustls` for creating `https://` connections.
3236
http-client-curl-rust-tls = ["http-client-curl", "curl/rustls"]
33-
### Implies `http-client` and adds support for http and https transports using the blocking version of `reqwest`.
37+
## Implies `http-client` and adds support for http and https transports using the blocking version of `reqwest`.
3438
http-client-reqwest = ["reqwest", "http-client"]
3539
## Stacks with `blocking-http-transport-reqwest` and enables `https://` via the `rustls` crate.
3640
http-client-reqwest-rust-tls = ["http-client-reqwest", "reqwest/rustls-tls"]

gix-transport/src/client/blocking_io/http/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use crate::{
1919
http::options::{HttpVersion, SslVersionRangeInclusive},
2020
ExtendedBufRead, HandleProgress, RequestWriter, SetServiceResponse,
2121
},
22-
capabilities::blocking_recv::Outcome,
22+
capabilities::blocking_recv::Handshake,
2323
MessageKind,
2424
},
2525
packetline::{blocking_io::StreamingPeekableIter, PacketLineRef},
@@ -403,11 +403,11 @@ impl<H: Http> blocking_io::Transport for Transport<H> {
403403
line_reader.as_read().read_to_end(&mut Vec::new())?;
404404
}
405405

406-
let Outcome {
406+
let Handshake {
407407
capabilities,
408408
refs,
409409
protocol: actual_protocol,
410-
} = Outcome::from_lines_with_version_detection(line_reader)?;
410+
} = Handshake::from_lines_with_version_detection(line_reader)?;
411411
self.actual_version = actual_protocol;
412412
self.service = Some(service);
413413
Ok(SetServiceResponse {

gix-transport/src/client/capabilities.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ impl Capabilities {
165165
}
166166
}
167167

168-
#[cfg(feature = "blocking-client")]
169168
///
169+
#[cfg(feature = "blocking-client")]
170170
pub mod blocking_recv {
171171
use std::io;
172172

@@ -178,8 +178,8 @@ pub mod blocking_recv {
178178
Protocol,
179179
};
180180

181-
/// Success outcome of [`Outcome::from_lines_with_version_detection`].
182-
pub struct Outcome<'a> {
181+
/// The information provided by the server upon first connection.
182+
pub struct Handshake<'a> {
183183
/// The [`Capabilities`] the remote advertised.
184184
pub capabilities: Capabilities,
185185
/// The remote refs as a [`io::BufRead`].
@@ -191,14 +191,14 @@ pub mod blocking_recv {
191191
pub protocol: Protocol,
192192
}
193193

194-
impl Outcome<'_> {
194+
impl Handshake<'_> {
195195
/// Read the capabilities and version advertisement from the given packetline reader.
196196
///
197197
/// If [`Protocol::V1`] was requested, or the remote decided to downgrade, the remote refs
198-
/// advertisement will also be included in the [`Outcome`].
198+
/// advertisement will also be included in the [`Handshake`].
199199
pub fn from_lines_with_version_detection<T: io::Read>(
200200
rd: &mut StreamingPeekableIter<T>,
201-
) -> Result<Outcome<'_>, client::Error> {
201+
) -> Result<Handshake<'_>, client::Error> {
202202
// NOTE that this is vitally important - it is turned on and stays on for all following requests so
203203
// we automatically abort if the server sends an ERR line anywhere.
204204
// We are sure this can't clash with binary data when sent due to the way the PACK
@@ -214,13 +214,13 @@ pub mod blocking_recv {
214214
Protocol::V1 => {
215215
let (capabilities, delimiter_position) = Capabilities::from_bytes(line.0)?;
216216
rd.peek_buffer_replace_and_truncate(delimiter_position, b'\n');
217-
Outcome {
217+
Handshake {
218218
capabilities,
219219
refs: Some(Box::new(rd.as_read())),
220220
protocol: Protocol::V1,
221221
}
222222
}
223-
Protocol::V2 => Outcome {
223+
Protocol::V2 => Handshake {
224224
capabilities: {
225225
let mut rd = rd.as_read();
226226
let mut buf = Vec::new();
@@ -243,7 +243,7 @@ pub mod blocking_recv {
243243
},
244244
}
245245
}
246-
None => Outcome {
246+
None => Handshake {
247247
capabilities: Capabilities::default(),
248248
refs: Some(Box::new(rd.as_read())),
249249
protocol: Protocol::V0,
@@ -253,9 +253,9 @@ pub mod blocking_recv {
253253
}
254254
}
255255

256+
///
256257
#[cfg(feature = "async-client")]
257258
#[allow(missing_docs)]
258-
///
259259
pub mod async_recv {
260260
use bstr::ByteVec;
261261
use futures_io::AsyncRead;
@@ -266,8 +266,8 @@ pub mod async_recv {
266266
Protocol,
267267
};
268268

269-
/// Success outcome of [`Outcome::from_lines_with_version_detection`].
270-
pub struct Outcome<'a> {
269+
/// The information provided by the server upon first connection.
270+
pub struct Handshake<'a> {
271271
/// The [`Capabilities`] the remote advertised.
272272
pub capabilities: Capabilities,
273273
/// The remote refs as an [`AsyncBufRead`].
@@ -279,14 +279,14 @@ pub mod async_recv {
279279
pub protocol: Protocol,
280280
}
281281

282-
impl Outcome<'_> {
282+
impl Handshake<'_> {
283283
/// Read the capabilities and version advertisement from the given packetline reader.
284284
///
285285
/// If [`Protocol::V1`] was requested, or the remote decided to downgrade, the remote refs
286-
/// advertisement will also be included in the [`Outcome`].
286+
/// advertisement will also be included in the [`Handshake`].
287287
pub async fn from_lines_with_version_detection<T: AsyncRead + Unpin>(
288288
rd: &mut StreamingPeekableIter<T>,
289-
) -> Result<Outcome<'_>, client::Error> {
289+
) -> Result<Handshake<'_>, client::Error> {
290290
// NOTE that this is vitally important - it is turned on and stays on for all following requests so
291291
// we automatically abort if the server sends an ERR line anywhere.
292292
// We are sure this can't clash with binary data when sent due to the way the PACK
@@ -302,13 +302,13 @@ pub mod async_recv {
302302
Protocol::V1 => {
303303
let (capabilities, delimiter_position) = Capabilities::from_bytes(line.0)?;
304304
rd.peek_buffer_replace_and_truncate(delimiter_position, b'\n');
305-
Outcome {
305+
Handshake {
306306
capabilities,
307307
refs: Some(Box::new(rd.as_read())),
308308
protocol: Protocol::V1,
309309
}
310310
}
311-
Protocol::V2 => Outcome {
311+
Protocol::V2 => Handshake {
312312
capabilities: {
313313
let mut rd = rd.as_read();
314314
let mut buf = Vec::new();
@@ -331,7 +331,7 @@ pub mod async_recv {
331331
},
332332
}
333333
}
334-
None => Outcome {
334+
None => Handshake {
335335
capabilities: Capabilities::default(),
336336
refs: Some(Box::new(rd.as_read())),
337337
protocol: Protocol::V0,

gix-transport/src/client/git/async_io.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::{
99
client::{
1010
self,
1111
async_io::{RequestWriter, SetServiceResponse},
12-
capabilities::async_recv::Outcome,
12+
capabilities::async_recv::Handshake,
1313
git::{self, ConnectionState},
1414
},
1515
packetline::{
@@ -96,11 +96,11 @@ where
9696
line_writer.flush().await?;
9797
}
9898

99-
let Outcome {
99+
let Handshake {
100100
capabilities,
101101
refs,
102102
protocol: actual_protocol,
103-
} = Outcome::from_lines_with_version_detection(&mut self.line_provider).await?;
103+
} = Handshake::from_lines_with_version_detection(&mut self.line_provider).await?;
104104
Ok(SetServiceResponse {
105105
actual_protocol,
106106
capabilities,

gix-transport/src/client/git/blocking_io.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::{
66
client::{
77
self,
88
blocking_io::{RequestWriter, SetServiceResponse},
9-
capabilities::blocking_recv::Outcome,
9+
capabilities::blocking_recv::Handshake,
1010
git::{self, ConnectionState},
1111
},
1212
packetline::{
@@ -91,11 +91,11 @@ where
9191
line_writer.flush()?;
9292
}
9393

94-
let Outcome {
94+
let Handshake {
9595
capabilities,
9696
refs,
9797
protocol: actual_protocol,
98-
} = Outcome::from_lines_with_version_detection(&mut self.line_provider)?;
98+
} = Handshake::from_lines_with_version_detection(&mut self.line_provider)?;
9999
Ok(SetServiceResponse {
100100
actual_protocol,
101101
capabilities,

gix-transport/tests/client/capabilities.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ use gix_packetline::async_io::{encode, StreamingPeekableIter};
44
#[cfg(all(feature = "blocking-client", not(feature = "async-client")))]
55
use gix_packetline::blocking_io::{encode, StreamingPeekableIter};
66
#[cfg(all(feature = "async-client", not(feature = "blocking-client")))]
7-
use gix_transport::client::capabilities::async_recv::Outcome;
7+
use gix_transport::client::capabilities::async_recv::Handshake;
88
#[cfg(all(feature = "blocking-client", not(feature = "async-client")))]
9-
use gix_transport::client::capabilities::blocking_recv::Outcome;
9+
use gix_transport::client::capabilities::blocking_recv::Handshake;
1010
use gix_transport::client::Capabilities;
1111

1212
#[test]
@@ -63,7 +63,7 @@ async fn from_lines_with_version_detection_v0() -> crate::Result {
6363
let mut buf = Vec::<u8>::new();
6464
encode::flush_to_write(&mut buf).await?;
6565
let mut stream = StreamingPeekableIter::new(buf.as_slice(), &[gix_packetline::PacketLineRef::Flush], false);
66-
let caps = Outcome::from_lines_with_version_detection(&mut stream)
66+
let caps = Handshake::from_lines_with_version_detection(&mut stream)
6767
.await
6868
.expect("we can parse V0 as very special case, useful for testing stateful connections in other crates")
6969
.capabilities;

0 commit comments

Comments
 (0)