discord-rpc-client/src/connection/windows.rs

34 lines
745 B
Rust

use std::{path::PathBuf, time};
use tokio::net::windows::named_pipe::{ClientOptions, NamedPipeClient};
use super::base::Connection;
use crate::error::Result;
#[derive(Debug)]
pub struct WindowsConnection {
socket: NamedPipeClient,
}
#[async_trait::async_trait]
impl Connection for WindowsConnection {
type Socket = NamedPipeClient;
fn socket(&mut self) -> &mut Self::Socket {
&mut self.socket
}
fn ipc_path() -> PathBuf {
PathBuf::from(r"\\.\pipe\")
}
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(())
}
}