Files
zed/crates/net/src/async_net.rs
T
Mohamad KhaniandClaude Fable 5 46c7879954 logiguard fork v2: patched GPUI on verified 8c74db0 tree
Rebuilt from the exact zed-industries/zed @ 8c74db00c4053d6c0a9037863d7bd048658da4ca
tree (previous orphan was based on a stale/wrong fetch). Same 3-file patch:
  - serial.rs: add SerialKind::KeyboardEnter
  - client.rs: store wl_keyboard.enter serial; add latest_serial_of()
  - window.rs: activate() uses keyboard-enter serial (Mutter focus gate)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-14 01:44:22 +03:30

70 lines
1.9 KiB
Rust

#[cfg(not(target_os = "windows"))]
pub use smol::net::unix::{UnixListener, UnixStream};
#[cfg(target_os = "windows")]
pub use windows::{UnixListener, UnixStream};
#[cfg(target_os = "windows")]
pub mod windows {
use std::{
io::Result,
path::Path,
pin::Pin,
task::{Context, Poll},
};
use smol::{
Async,
io::{AsyncRead, AsyncWrite},
};
pub struct UnixListener(Async<crate::UnixListener>);
impl UnixListener {
pub fn bind<P: AsRef<Path>>(path: P) -> Result<Self> {
Ok(UnixListener(Async::new(crate::UnixListener::bind(path)?)?))
}
pub async fn accept(&self) -> Result<(UnixStream, ())> {
let (sock, _) = self.0.read_with(|listener| listener.accept()).await?;
Ok((UnixStream(Async::new(sock)?), ()))
}
}
pub struct UnixStream(Async<crate::UnixStream>);
impl UnixStream {
pub async fn connect<P: AsRef<Path>>(path: P) -> Result<Self> {
Ok(UnixStream(Async::new(crate::UnixStream::connect(path)?)?))
}
}
impl AsyncRead for UnixStream {
fn poll_read(
mut self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &mut [u8],
) -> Poll<Result<usize>> {
Pin::new(&mut self.0).poll_read(cx, buf)
}
}
impl AsyncWrite for UnixStream {
fn poll_write(
mut self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &[u8],
) -> Poll<Result<usize>> {
Pin::new(&mut self.0).poll_write(cx, buf)
}
fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>> {
Pin::new(&mut self.0).poll_flush(cx)
}
fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>> {
Pin::new(&mut self.0).poll_close(cx)
}
}
}