Skip to content

Commit

Permalink
speculative windows build fix
Browse files Browse the repository at this point in the history
  • Loading branch information
wez committed May 13, 2024
1 parent eb6fc75 commit ccc32fa
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
7 changes: 7 additions & 0 deletions async_ossl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ impl std::os::windows::io::AsRawSocket for AsyncSslStream {
}
}

#[cfg(windows)]
impl std::os::windows::io::AsSocket for AsyncSslStream {
fn as_socket(&self) -> std::os::windows::io::BorrowedSocket {
self.s.get_ref().as_socket()
}
}

impl AsRawDesc for AsyncSslStream {}

impl std::io::Read for AsyncSslStream {
Expand Down
12 changes: 9 additions & 3 deletions filedescriptor/src/windows.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{
AsRawFileDescriptor, AsRawSocketDescriptor, Error, FileDescriptor, FromRawFileDescriptor,
FromRawSocketDescriptor, IntoRawFileDescriptor, IntoRawSocketDescriptor, OwnedHandle, Pipe,
Result, StdioDescriptor,
AsRawFileDescriptor, AsRawSocketDescriptor, AsSocket, Error, FileDescriptor,
FromRawFileDescriptor, FromRawSocketDescriptor, IntoRawFileDescriptor, IntoRawSocketDescriptor,
OwnedHandle, Pipe, Result, StdioDescriptor,
};
use std::io::{self, Error as IoError};
use std::os::windows::prelude::*;
Expand Down Expand Up @@ -320,6 +320,12 @@ impl AsRawSocket for FileDescriptor {
}
}

impl AsSocket for FileDescriptor {
fn as_socket(&self) -> BorrowedSocket {
unsafe { BorrowedSocket::borrow_raw(self.as_raw_socket()) }
}
}

impl FromRawSocket for FileDescriptor {
unsafe fn from_raw_socket(handle: RawSocket) -> FileDescriptor {
Self {
Expand Down
7 changes: 7 additions & 0 deletions wezterm-client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,13 @@ impl std::os::windows::io::AsRawSocket for SshStream {
}
}

#[cfg(windows)]
impl std::os::windows::io::AsSocket for SshStream {
fn as_socket(&self) -> std::os::windows::io::BorrowedSocket {
self.stdout.as_socket()
}
}

impl Read for SshStream {
fn read(&mut self, buf: &mut [u8]) -> Result<usize, std::io::Error> {
self.stdout.read(buf)
Expand Down
2 changes: 1 addition & 1 deletion wezterm-mux-server-impl/src/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use smol::Async;
#[cfg(unix)]
pub trait AsRawDesc: std::os::unix::io::AsRawFd + std::os::fd::AsFd {}
#[cfg(windows)]
pub trait AsRawDesc: std::os::windows::io::AsRawSocket {}
pub trait AsRawDesc: std::os::windows::io::AsRawSocket + std::os::windows::io::AsSocket {}

impl AsRawDesc for UnixStream {}
impl AsRawDesc for AsyncSslStream {}
Expand Down

0 comments on commit ccc32fa

Please sign in to comment.