Skip to content

Commit 0357575

Browse files
authored
Merge pull request #27 from bk-rs/fix-windows
Fix compile on windows
2 parents e06ad0d + 677d046 commit 0357575

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

async-ssh2-lite/src/agent.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ where
4444
{
4545
pub fn new(stream: S) -> Result<Self, Error> {
4646
let mut session = get_session(None)?;
47-
session.set_tcp_stream(stream.as_raw_socket());
47+
session.set_tcp_stream(crate::util::RawSocketWrapper(stream.as_raw_socket()));
4848

4949
let stream = Arc::new(stream);
5050

async-ssh2-lite/src/session.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ where
6262
configuration: impl Into<Option<SessionConfiguration>>,
6363
) -> Result<Self, Error> {
6464
let mut session = get_session(configuration)?;
65-
session.set_tcp_stream(stream.as_raw_socket());
65+
session.set_tcp_stream(crate::util::RawSocketWrapper(stream.as_raw_socket()));
6666

6767
let stream = Arc::new(stream);
6868

async-ssh2-lite/src/util.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,14 @@ impl ConnectInfo {
2929
Self::Unix(path.as_ref().into())
3030
}
3131
}
32+
33+
#[cfg(windows)]
34+
pub struct RawSocketWrapper(pub std::os::windows::io::RawSocket);
35+
36+
#[cfg(windows)]
37+
impl std::os::windows::io::AsRawSocket for RawSocketWrapper {
38+
#[inline]
39+
fn as_raw_socket(&self) -> std::os::windows::io::RawSocket {
40+
self.0
41+
}
42+
}

0 commit comments

Comments
 (0)