@@ -17,10 +17,7 @@ use std::process;
1717use super :: { CommandProvider , CommandRunnable } ;
1818
1919#[ derive( Clone ) ]
20- pub struct Generic < H : Host > {
21- host : H
22- }
23-
20+ pub struct Generic ;
2421struct LocalGeneric ;
2522struct RemoteGeneric ;
2623
@@ -31,42 +28,42 @@ pub enum GenericRunnable {
3128 Exec ( String , Vec < String > ) ,
3229}
3330
34- impl < H : Host + ' static > Provider < H > for Generic < H > {
31+ impl < H : Host + ' static > Provider < H > for Generic {
3532 fn available ( host : & H ) -> Box < Future < Item = bool , Error = Error > > {
3633 match host. get_type ( ) {
37- HostType :: Local ( l ) => LocalGeneric :: available ( l ) ,
34+ HostType :: Local ( _ ) => LocalGeneric :: available ( ) ,
3835 HostType :: Remote ( r) => RemoteGeneric :: available ( r) ,
3936 }
4037 }
4138
42- fn try_new ( host : & H ) -> Box < Future < Item = Option < Generic < H > > , Error = Error > > {
39+ fn try_new ( host : & H ) -> Box < Future < Item = Option < Generic > , Error = Error > > {
4340 let host = host. clone ( ) ;
4441 Box :: new ( Self :: available ( & host)
4542 . and_then ( |available| {
4643 if available {
47- future:: ok ( Some ( Generic { host } ) )
44+ future:: ok ( Some ( Generic ) )
4845 } else {
4946 future:: ok ( None )
5047 }
5148 } ) )
5249 }
5350}
5451
55- impl < H : Host + ' static > CommandProvider < H > for Generic < H > {
56- fn exec ( & mut self , cmd : & str , shell : & [ String ] ) -> Box < Future < Item = CommandResult , Error = Error > > {
57- match self . host . get_type ( ) {
58- HostType :: Local ( l ) => LocalGeneric :: exec ( l , cmd, shell) ,
52+ impl < H : Host + ' static > CommandProvider < H > for Generic {
53+ fn exec ( & self , host : & H , cmd : & str , shell : & [ String ] ) -> Box < Future < Item = CommandResult , Error = Error > > {
54+ match host. get_type ( ) {
55+ HostType :: Local ( _ ) => LocalGeneric :: exec ( cmd, shell) ,
5956 HostType :: Remote ( r) => RemoteGeneric :: exec ( r, cmd, shell) ,
6057 }
6158 }
6259}
6360
6461impl LocalGeneric {
65- fn available ( _ : & Local ) -> Box < Future < Item = bool , Error = Error > > {
62+ fn available ( ) -> Box < Future < Item = bool , Error = Error > > {
6663 Box :: new ( future:: ok ( cfg ! ( unix) ) )
6764 }
6865
69- fn exec ( _ : & Local , cmd : & str , shell : & [ String ] ) -> Box < Future < Item = CommandResult , Error = Error > > {
66+ fn exec ( cmd : & str , shell : & [ String ] ) -> Box < Future < Item = CommandResult , Error = Error > > {
7067 let cmd_owned = cmd. to_owned ( ) ;
7168 let shell_owned = shell. to_owned ( ) ;
7269
@@ -113,10 +110,10 @@ impl RemoteGeneric {
113110}
114111
115112impl Executable for GenericRunnable {
116- fn exec ( self , host : & Local ) -> Box < Future < Item = Box < Serialize > , Error = Error > > {
113+ fn exec ( self , _ : & Local ) -> Box < Future < Item = Box < Serialize > , Error = Error > > {
117114 match self {
118- GenericRunnable :: Available => Box :: new ( LocalGeneric :: available ( host ) . map ( |b| Box :: new ( b) as Box < Serialize > ) ) ,
119- GenericRunnable :: Exec ( cmd, shell) => Box :: new ( LocalGeneric :: exec ( host , & cmd, & shell) . map ( |r| Box :: new ( r) as Box < Serialize > ) ) ,
115+ GenericRunnable :: Available => Box :: new ( LocalGeneric :: available ( ) . map ( |b| Box :: new ( b) as Box < Serialize > ) ) ,
116+ GenericRunnable :: Exec ( cmd, shell) => Box :: new ( LocalGeneric :: exec ( & cmd, & shell) . map ( |r| Box :: new ( r) as Box < Serialize > ) ) ,
120117 }
121118 }
122119}
0 commit comments