1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-23 13:21:38 +03:00

add very bare bones skeleton for unix domain socket bits

This commit is contained in:
Wez Furlong 2019-03-03 05:08:58 -08:00
parent 8fa619d23f
commit d71ac26b93
5 changed files with 45 additions and 0 deletions

View File

@ -39,6 +39,9 @@ path = "term"
[dependencies.termwiz]
path = "termwiz"
[target."cfg(windows)".dependencies.uds_windows]
version = "0.1"
[target."cfg(windows)".dependencies.winapi]
features = [
"winuser",

View File

@ -22,6 +22,7 @@ mod guicommon;
mod guiloop;
mod mux;
mod opengl;
mod server;
use crate::guicommon::tabs::Tab;
use crate::guiloop::GuiSelection;
use crate::guiloop::GuiSystem;

1
src/server/client.rs Normal file
View File

@ -0,0 +1 @@
pub struct Client {}

33
src/server/listener.rs Normal file
View File

@ -0,0 +1,33 @@
use crate::server::{UnixListener, UnixStream};
use failure::Error;
use std::io::{Read, Write};
pub trait SocketLike: Read + Write + Send {}
pub trait Acceptor {
fn accept(&self) -> Result<Box<SocketLike>, Error>;
}
impl SocketLike for UnixStream {}
impl Acceptor for UnixListener {
fn accept(&self) -> Result<Box<SocketLike>, Error> {
let (stream, _addr) = UnixListener::accept(self)?;
let timeout = std::time::Duration::new(60, 0);
stream.set_read_timeout(Some(timeout))?;
stream.set_write_timeout(Some(timeout))?;
Ok(Box::new(stream))
}
}
pub struct Listener {
acceptor: Box<Acceptor>,
}
impl Listener {
pub fn new(acceptor: Box<Acceptor>) -> Self {
Self { acceptor }
}
}
pub struct ClientSession {}

7
src/server/mod.rs Normal file
View File

@ -0,0 +1,7 @@
#[cfg(unix)]
use std::os::unix::net::{SocketAddr, UnixListener, UnixStream};
#[cfg(windows)]
use uds_windows::{SocketAddr, UnixListener, UnixStream};
pub mod client;
pub mod listener;