2022-02-03 09:52:53 -05:00
|
|
|
use std::{path::PathBuf, time};
|
2018-04-02 17:42:57 -04:00
|
|
|
|
2022-02-03 15:56:37 -05:00
|
|
|
use tokio::net::windows::named_pipe::{ClientOptions, NamedPipeClient};
|
2018-04-02 17:42:57 -04:00
|
|
|
|
2022-02-03 15:56:37 -05:00
|
|
|
use super::base::Connection;
|
|
|
|
use crate::error::Result;
|
2018-04-02 17:42:57 -04:00
|
|
|
|
2022-02-03 09:52:53 -05:00
|
|
|
#[derive(Debug)]
|
2018-04-02 17:42:57 -04:00
|
|
|
pub struct WindowsConnection {
|
2022-02-03 15:56:37 -05:00
|
|
|
socket: NamedPipeClient,
|
2018-04-02 17:42:57 -04:00
|
|
|
}
|
|
|
|
|
2022-02-03 15:56:37 -05:00
|
|
|
#[async_trait::async_trait]
|
2018-04-02 17:42:57 -04:00
|
|
|
impl Connection for WindowsConnection {
|
2022-02-03 15:56:37 -05:00
|
|
|
type Socket = NamedPipeClient;
|
2018-04-03 06:03:08 -04:00
|
|
|
|
2022-02-03 15:56:37 -05:00
|
|
|
fn socket(&mut self) -> &mut Self::Socket {
|
|
|
|
&mut self.socket
|
2018-04-02 17:42:57 -04:00
|
|
|
}
|
|
|
|
|
2018-04-03 06:03:08 -04:00
|
|
|
fn ipc_path() -> PathBuf {
|
|
|
|
PathBuf::from(r"\\.\pipe\")
|
2018-04-02 17:42:57 -04:00
|
|
|
}
|
|
|
|
|
2022-02-03 15:56:37 -05:00
|
|
|
async fn connect() -> Result<Self> {
|
|
|
|
let connection_name = Self::socket_path(0);
|
|
|
|
Ok(Self { socket: ClientOptions::new().open(connection_name)? })
|
|
|
|
}
|
|
|
|
|
|
|
|
async fn disconnect(mut self) -> Result<()> {
|
|
|
|
Ok(())
|
2018-04-02 17:42:57 -04:00
|
|
|
}
|
|
|
|
}
|