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