style(ipc): fix formatting
This commit is contained in:
parent
ad79f58dd4
commit
f22037beda
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use serde::{de::DeserializeOwned, Serialize};
|
use serde::{de::DeserializeOwned, Serialize};
|
||||||
use std::{path::Path};
|
use std::path::Path;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
|
@ -58,7 +58,10 @@ pub fn server<Event: Send + Sync + DeserializeOwned + Serialize>(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(target_os = "windows"))]
|
#[cfg(not(target_os = "windows"))]
|
||||||
pub fn client<Event: Serialize + DeserializeOwned>(id: &str, parent_dir: &Path) -> Result<impl IPCClient<Event>> {
|
pub fn client<Event: Serialize + DeserializeOwned>(
|
||||||
|
id: &str,
|
||||||
|
parent_dir: &Path,
|
||||||
|
) -> Result<impl IPCClient<Event>> {
|
||||||
let client = unix::UnixIPCClient::new(id, parent_dir)?;
|
let client = unix::UnixIPCClient::new(id, parent_dir)?;
|
||||||
Ok(client)
|
Ok(client)
|
||||||
}
|
}
|
||||||
|
@ -73,7 +76,10 @@ pub fn server<Event: Send + Sync + DeserializeOwned + Serialize>(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
pub fn client<Event: Serialize + DeserializeOwned>(id: &str, _: &Path) -> Result<impl IPCClient<Event>> {
|
pub fn client<Event: Serialize + DeserializeOwned>(
|
||||||
|
id: &str,
|
||||||
|
_: &Path,
|
||||||
|
) -> Result<impl IPCClient<Event>> {
|
||||||
let client = windows::WinIPCClient::new(id)?;
|
let client = windows::WinIPCClient::new(id)?;
|
||||||
Ok(client)
|
Ok(client)
|
||||||
}
|
}
|
||||||
|
@ -101,9 +107,7 @@ pub enum IPCClientError {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use std::{
|
use std::sync::mpsc::channel;
|
||||||
sync::{mpsc::channel},
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
@ -169,7 +173,8 @@ mod tests {
|
||||||
let server = server::<Event>("testespansoipcmultiplesync", &std::env::temp_dir()).unwrap();
|
let server = server::<Event>("testespansoipcmultiplesync", &std::env::temp_dir()).unwrap();
|
||||||
|
|
||||||
let client_handle = std::thread::spawn(move || {
|
let client_handle = std::thread::spawn(move || {
|
||||||
let mut client = client::<Event>("testespansoipcmultiplesync", &std::env::temp_dir()).unwrap();
|
let mut client =
|
||||||
|
client::<Event>("testespansoipcmultiplesync", &std::env::temp_dir()).unwrap();
|
||||||
|
|
||||||
let response = client.send_sync(Event::Sync("test".to_owned())).unwrap();
|
let response = client.send_sync(Event::Sync("test".to_owned())).unwrap();
|
||||||
|
|
||||||
|
|
|
@ -17,14 +17,14 @@
|
||||||
* along with espanso. If not, see <https://www.gnu.org/licenses/>.
|
* along with espanso. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use crate::{EventHandlerResponse, IPCClientError, util::read_line};
|
use crate::{util::read_line, EventHandlerResponse, IPCClientError};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use log::{error, info};
|
use log::{error, info};
|
||||||
use serde::{de::DeserializeOwned, Serialize};
|
use serde::{de::DeserializeOwned, Serialize};
|
||||||
use std::{
|
use std::{
|
||||||
io::{Write},
|
io::Write,
|
||||||
os::unix::net::{UnixListener, UnixStream},
|
os::unix::net::{UnixListener, UnixStream},
|
||||||
path::{Path},
|
path::Path,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{EventHandler, IPCClient, IPCServer};
|
use crate::{EventHandler, IPCClient, IPCServer};
|
||||||
|
|
|
@ -17,16 +17,14 @@
|
||||||
* along with espanso. If not, see <https://www.gnu.org/licenses/>.
|
* along with espanso. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use crate::util::read_line;
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use log::{error, info};
|
use log::{error, info};
|
||||||
use named_pipe::{ConnectingServer, PipeClient, PipeOptions};
|
use named_pipe::{ConnectingServer, PipeClient, PipeOptions};
|
||||||
use serde::{de::DeserializeOwned, Serialize};
|
use serde::{de::DeserializeOwned, Serialize};
|
||||||
use std::{io::{Write}};
|
use std::io::Write;
|
||||||
use crate::util::read_line;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{EventHandler, EventHandlerResponse, IPCClient, IPCClientError, IPCServer};
|
||||||
EventHandler, EventHandlerResponse, IPCClient, IPCClientError, IPCServer,
|
|
||||||
};
|
|
||||||
|
|
||||||
const DEFAULT_CLIENT_TIMEOUT: u32 = 2000;
|
const DEFAULT_CLIENT_TIMEOUT: u32 = 2000;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user