1
1
pub use crate :: client:: non_io_types:: connect:: { Error , Options } ;
2
2
3
- #[ cfg( feature = "async-std" ) ]
4
3
pub ( crate ) mod function {
5
- use crate :: client:: { git , non_io_types:: connect:: Error } ;
4
+ use crate :: client:: non_io_types:: connect:: Error ;
6
5
7
6
/// A general purpose connector connecting to a repository identified by the given `url`.
8
7
///
9
8
/// This includes connections to
10
- /// [git daemons][crate::client::git::connect()] only at the moment.
9
+ /// [git daemons][crate::client::git::connect()] and `ssh`,
11
10
///
12
11
/// Use `options` to further control specifics of the transport resulting from the connection.
13
12
pub async fn connect < Url , E > (
@@ -18,28 +17,30 @@ pub(crate) mod function {
18
17
Url : TryInto < gix_url:: Url , Error = E > ,
19
18
gix_url:: parse:: Error : From < E > ,
20
19
{
21
- let mut url = url. try_into ( ) . map_err ( gix_url:: parse:: Error :: from) ?;
20
+ let url = url. try_into ( ) . map_err ( gix_url:: parse:: Error :: from) ?;
22
21
Ok ( match url. scheme {
22
+ #[ cfg( feature = "async-std" ) ]
23
23
gix_url:: Scheme :: Git => {
24
24
if url. user ( ) . is_some ( ) {
25
25
return Err ( Error :: UnsupportedUrlTokens {
26
26
url : url. to_bstring ( ) ,
27
27
scheme : url. scheme ,
28
28
} ) ;
29
29
}
30
- let path = std :: mem :: take ( & mut url . path ) ;
30
+
31
31
Box :: new (
32
- git:: Connection :: new_tcp (
32
+ crate :: client :: git:: Connection :: new_tcp (
33
33
url. host ( ) . expect ( "host is present in url" ) ,
34
34
url. port ,
35
- path,
35
+ url . path . clone ( ) ,
36
36
options. version ,
37
37
options. trace ,
38
38
)
39
39
. await
40
40
. map_err ( |e| Box :: new ( e) as Box < dyn std:: error:: Error + Send + Sync > ) ?,
41
41
)
42
42
}
43
+ #[ cfg( feature = "russh" ) ]
43
44
gix_url:: Scheme :: Ssh => {
44
45
Box :: new ( crate :: client:: async_io:: ssh:: connect ( url, options. version , options. trace ) . await ?)
45
46
}
0 commit comments