Skip to content

Commit 0e0c436

Browse files
committed
Simplify Session::{connect, connect_mux}
Signed-off-by: Jiahao XU <[email protected]>
1 parent ee02da7 commit 0e0c436

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

src/builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ impl SessionBuilder {
203203
.await
204204
}
205205

206-
pub(super) async fn connect_impl(
206+
async fn connect_impl(
207207
&self,
208208
destination: &str,
209209
f: fn(TempDir) -> Session,

src/session.rs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,10 @@ impl Session {
108108
#[cfg(feature = "process-mux")]
109109
#[cfg_attr(docsrs, doc(cfg(feature = "process-mux")))]
110110
pub async fn connect<S: AsRef<str>>(destination: S, check: KnownHosts) -> Result<Self, Error> {
111-
Self::connect_impl(destination.as_ref(), check, Session::new_process_mux).await
111+
SessionBuilder::default()
112+
.known_hosts_check(check)
113+
.connect(destination)
114+
.await
112115
}
113116

114117
/// Connect to the host at the given `host` over SSH using native mux impl, which
@@ -130,17 +133,10 @@ impl Session {
130133
destination: S,
131134
check: KnownHosts,
132135
) -> Result<Self, Error> {
133-
Self::connect_impl(destination.as_ref(), check, Session::new_native_mux).await
134-
}
135-
136-
async fn connect_impl(
137-
destination: &str,
138-
check: KnownHosts,
139-
f: fn(TempDir) -> Session,
140-
) -> Result<Self, Error> {
141-
let mut s = SessionBuilder::default();
142-
s.known_hosts_check(check);
143-
s.connect_impl(destination, f).await
136+
SessionBuilder::default()
137+
.known_hosts_check(check)
138+
.connect_mux(destination)
139+
.await
144140
}
145141

146142
/// Check the status of the underlying SSH connection.

0 commit comments

Comments
 (0)