File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ use crate::*;
9
9
/// - `From<&'a Path> for Socket<'a>`
10
10
/// - `From<PathBuf> for Socket<'a>`
11
11
/// - `From<Box<Path>> for Socket<'a>`
12
+ /// - `From<(IpAddr, u16)> for Socket<'static>`
12
13
///
13
14
/// ## Changed
14
15
/// - [`Session::request_port_forward`] now takes `impl Into<...>`
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ use std::ffi::OsStr;
7
7
use std:: borrow:: Cow ;
8
8
use std:: fmt;
9
9
use std:: io;
10
- use std:: net:: { SocketAddr , ToSocketAddrs } ;
10
+ use std:: net:: { self , SocketAddr , ToSocketAddrs } ;
11
11
use std:: path:: { Path , PathBuf } ;
12
12
13
13
/// Type of forwarding
@@ -52,6 +52,19 @@ impl From<SocketAddr> for Socket<'static> {
52
52
Socket :: TcpSocket ( addr)
53
53
}
54
54
}
55
+
56
+ macro_rules! impl_from_addr {
57
+ ( $ip: ty) => {
58
+ impl From <( $ip, u16 ) > for Socket <' static > {
59
+ fn from( addr: ( $ip, u16 ) ) -> Self {
60
+ Socket :: new( & addr) . unwrap( )
61
+ }
62
+ }
63
+ } ;
64
+ }
65
+
66
+ impl_from_addr ! ( net:: IpAddr ) ;
67
+
55
68
impl < ' a > From < Cow < ' a , Path > > for Socket < ' a > {
56
69
fn from ( path : Cow < ' a , Path > ) -> Self {
57
70
Socket :: UnixSocket { path }
You can’t perform that action at this time.
0 commit comments