Skip to content

Commit e082d95

Browse files
committed
Added From<PathBuf> for Socket<'a>
Signed-off-by: Jiahao XU <[email protected]>
1 parent 932aa49 commit e082d95

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/changelog.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use crate::*;
77
/// - `From<SocketAddr> for Socket<'static>`
88
/// - `From<Cow<'a, Path>> for Socket<'a>`
99
/// - `From<&'a Path> for Socket<'a>`
10+
/// - `From<PathBuf> for Socket<'a>`
1011
///
1112
/// ## Changed
1213
/// - [`Session::request_port_forward`] now takes `impl Into<...>`

src/port_forwarding.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::borrow::Cow;
88
use std::fmt;
99
use std::io;
1010
use std::net::{SocketAddr, ToSocketAddrs};
11-
use std::path::Path;
11+
use std::path::{Path, PathBuf};
1212

1313
/// Type of forwarding
1414
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
@@ -66,6 +66,14 @@ impl<'a> From<&'a Path> for Socket<'a> {
6666
}
6767
}
6868

69+
impl From<PathBuf> for Socket<'static> {
70+
fn from(path: PathBuf) -> Self {
71+
Socket::UnixSocket {
72+
path: Cow::Owned(path),
73+
}
74+
}
75+
}
76+
6977
impl Socket<'_> {
7078
/// Create a new TcpSocket
7179
pub fn new<T: ToSocketAddrs>(addr: &T) -> Result<Socket<'static>, io::Error> {

0 commit comments

Comments
 (0)