@@ -52,21 +52,21 @@ macro_rules! delegate {
52
52
}
53
53
54
54
/// If a command is `OverSsh` then it can be executed over an SSH session.
55
- ///
55
+ ///
56
56
/// Primarily a way to allow `std::process::Command` to be turned directly into an `openssh::Command`.
57
57
pub trait OverSsh {
58
58
/// Given an ssh session, return a command that can be executed over that ssh session.
59
59
///
60
60
/// ### Notes
61
- ///
61
+ ///
62
62
/// The command to be executed on the remote machine should not explicitly
63
- /// set environment variables or the current working directory. It errors if the source command
63
+ /// set environment variables or the current working directory. It errors if the source command
64
64
/// has environment variables or a current working directory set, since `openssh` doesn't (yet) have
65
65
/// a method to set environment variables and `ssh` doesn't support setting a current working directory
66
66
/// outside of `bash/dash/zsh` (which is not always available).
67
- ///
67
+ ///
68
68
/// ### Examples
69
- ///
69
+ ///
70
70
/// 1. Consider the implementation of `OverSsh` for `std::process::Command`. Let's build a
71
71
/// `ls -l -a -h` command and execute it over an SSH session.
72
72
///
@@ -93,7 +93,7 @@ pub trait OverSsh {
93
93
/// ```
94
94
/// 2. Building a command with environment variables or a current working directory set will
95
95
/// results in an error.
96
- ///
96
+ ///
97
97
/// ```no_run
98
98
/// # #[tokio::main(flavor = "current_thread")]
99
99
/// async fn main() -> Result<(), Box<dyn std::error::Error>> {
@@ -111,12 +111,17 @@ pub trait OverSsh {
111
111
/// }
112
112
///
113
113
/// ```
114
- fn over_ssh < ' session > ( & self , session : & ' session Session ) -> Result < crate :: Command < ' session > , crate :: Error > ;
114
+ fn over_ssh < ' session > (
115
+ & self ,
116
+ session : & ' session Session ,
117
+ ) -> Result < crate :: Command < ' session > , crate :: Error > ;
115
118
}
116
119
117
120
impl OverSsh for std:: process:: Command {
118
- fn over_ssh < ' session > ( & self , session : & ' session Session ) -> Result < Command < ' session > , crate :: Error > {
119
-
121
+ fn over_ssh < ' session > (
122
+ & self ,
123
+ session : & ' session Session ,
124
+ ) -> Result < Command < ' session > , crate :: Error > {
120
125
// I'd really like `!self.get_envs().is_empty()` here, but that's
121
126
// behind a `exact_size_is_empty` feature flag.
122
127
if self . get_envs ( ) . len ( ) > 0 {
@@ -137,7 +142,10 @@ impl OverSsh for std::process::Command {
137
142
}
138
143
139
144
impl OverSsh for tokio:: process:: Command {
140
- fn over_ssh < ' session > ( & self , session : & ' session Session ) -> Result < Command < ' session > , crate :: Error > {
145
+ fn over_ssh < ' session > (
146
+ & self ,
147
+ session : & ' session Session ,
148
+ ) -> Result < Command < ' session > , crate :: Error > {
141
149
self . as_std ( ) . over_ssh ( session)
142
150
}
143
151
}
@@ -146,7 +154,10 @@ impl<S> OverSsh for &S
146
154
where
147
155
S : OverSsh ,
148
156
{
149
- fn over_ssh < ' session > ( & self , session : & ' session Session ) -> Result < Command < ' session > , crate :: Error > {
157
+ fn over_ssh < ' session > (
158
+ & self ,
159
+ session : & ' session Session ,
160
+ ) -> Result < Command < ' session > , crate :: Error > {
150
161
<S as OverSsh >:: over_ssh ( self , session)
151
162
}
152
163
}
@@ -155,12 +166,14 @@ impl<S> OverSsh for &mut S
155
166
where
156
167
S : OverSsh ,
157
168
{
158
- fn over_ssh < ' session > ( & self , session : & ' session Session ) -> Result < Command < ' session > , crate :: Error > {
169
+ fn over_ssh < ' session > (
170
+ & self ,
171
+ session : & ' session Session ,
172
+ ) -> Result < Command < ' session > , crate :: Error > {
159
173
<S as OverSsh >:: over_ssh ( self , session)
160
174
}
161
175
}
162
176
163
-
164
177
/// A remote process builder, providing fine-grained control over how a new remote process should
165
178
/// be spawned.
166
179
///
0 commit comments