@@ -52,21 +52,21 @@ macro_rules! delegate {
5252}
5353
5454/// If a command is `OverSsh` then it can be executed over an SSH session.
55- ///
55+ ///
5656/// Primarily a way to allow `std::process::Command` to be turned directly into an `openssh::Command`.
5757pub trait OverSsh {
5858 /// Given an ssh session, return a command that can be executed over that ssh session.
5959 ///
6060 /// ### Notes
61- ///
61+ ///
6262 /// 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
6464 /// has environment variables or a current working directory set, since `openssh` doesn't (yet) have
6565 /// a method to set environment variables and `ssh` doesn't support setting a current working directory
6666 /// outside of `bash/dash/zsh` (which is not always available).
67- ///
67+ ///
6868 /// ### Examples
69- ///
69+ ///
7070 /// 1. Consider the implementation of `OverSsh` for `std::process::Command`. Let's build a
7171 /// `ls -l -a -h` command and execute it over an SSH session.
7272 ///
@@ -93,7 +93,7 @@ pub trait OverSsh {
9393 /// ```
9494 /// 2. Building a command with environment variables or a current working directory set will
9595 /// results in an error.
96- ///
96+ ///
9797 /// ```no_run
9898 /// # #[tokio::main(flavor = "current_thread")]
9999 /// async fn main() -> Result<(), Box<dyn std::error::Error>> {
@@ -111,12 +111,17 @@ pub trait OverSsh {
111111 /// }
112112 ///
113113 /// ```
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 > ;
115118}
116119
117120impl 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 > {
120125 // I'd really like `!self.get_envs().is_empty()` here, but that's
121126 // behind a `exact_size_is_empty` feature flag.
122127 if self . get_envs ( ) . len ( ) > 0 {
@@ -137,7 +142,10 @@ impl OverSsh for std::process::Command {
137142}
138143
139144impl 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 > {
141149 self . as_std ( ) . over_ssh ( session)
142150 }
143151}
@@ -146,7 +154,10 @@ impl<S> OverSsh for &S
146154where
147155 S : OverSsh ,
148156{
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 > {
150161 <S as OverSsh >:: over_ssh ( self , session)
151162 }
152163}
@@ -155,12 +166,14 @@ impl<S> OverSsh for &mut S
155166where
156167 S : OverSsh ,
157168{
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 > {
159173 <S as OverSsh >:: over_ssh ( self , session)
160174 }
161175}
162176
163-
164177/// A remote process builder, providing fine-grained control over how a new remote process should
165178/// be spawned.
166179///
0 commit comments