From f22037bedae1465b5096689a2bc7a2504beb5121 Mon Sep 17 00:00:00 2001 From: Federico Terzi Date: Wed, 6 Oct 2021 18:39:01 +0200 Subject: [PATCH] style(ipc): fix formatting --- espanso-ipc/src/lib.rs | 31 ++++++++++++++++++------------- espanso-ipc/src/unix.rs | 8 ++++---- espanso-ipc/src/util.rs | 2 +- espanso-ipc/src/windows.rs | 8 +++----- 4 files changed, 26 insertions(+), 23 deletions(-) diff --git a/espanso-ipc/src/lib.rs b/espanso-ipc/src/lib.rs index 6c6d1ac..1ba7b11 100644 --- a/espanso-ipc/src/lib.rs +++ b/espanso-ipc/src/lib.rs @@ -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( } #[cfg(not(target_os = "windows"))] -pub fn client(id: &str, parent_dir: &Path) -> Result> { +pub fn client( + id: &str, + parent_dir: &Path, +) -> Result> { let client = unix::UnixIPCClient::new(id, parent_dir)?; Ok(client) } @@ -73,7 +76,10 @@ pub fn server( } #[cfg(target_os = "windows")] -pub fn client(id: &str, _: &Path) -> Result> { +pub fn client( + id: &str, + _: &Path, +) -> Result> { 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}; @@ -119,7 +123,7 @@ mod tests { #[test] fn ipc_async_message() { let server = server::("testespansoipcasync", &std::env::temp_dir()).unwrap(); - + let client_handle = std::thread::spawn(move || { let mut client = client::("testespansoipcasync", &std::env::temp_dir()).unwrap(); @@ -143,7 +147,7 @@ mod tests { #[test] fn ipc_sync_message() { let server = server::("testespansoipcsync", &std::env::temp_dir()).unwrap(); - + let client_handle = std::thread::spawn(move || { let mut client = client::("testespansoipcsync", &std::env::temp_dir()).unwrap(); @@ -167,9 +171,10 @@ mod tests { #[test] fn ipc_multiple_sync_with_delay_message() { let server = server::("testespansoipcmultiplesync", &std::env::temp_dir()).unwrap(); - + let client_handle = std::thread::spawn(move || { - let mut client = client::("testespansoipcmultiplesync", &std::env::temp_dir()).unwrap(); + let mut client = + client::("testespansoipcmultiplesync", &std::env::temp_dir()).unwrap(); let response = client.send_sync(Event::Sync("test".to_owned())).unwrap(); @@ -198,7 +203,7 @@ mod tests { let server = server::("testespansoipcmultiple", &std::env::temp_dir()).unwrap(); let (tx, rx) = channel(); - + let client_handle = std::thread::spawn(move || { let mut client = client::("testespansoipcmultiple", &std::env::temp_dir()).unwrap(); @@ -234,10 +239,10 @@ mod tests { client_handle2.join().unwrap(); } - #[test] + #[test] fn ipc_sync_big_payload_message() { let server = server::("testespansoipcsyncbig", &std::env::temp_dir()).unwrap(); - + let client_handle = std::thread::spawn(move || { let mut client = client::("testespansoipcsyncbig", &std::env::temp_dir()).unwrap(); diff --git a/espanso-ipc/src/unix.rs b/espanso-ipc/src/unix.rs index d43aa44..4ba4336 100644 --- a/espanso-ipc/src/unix.rs +++ b/espanso-ipc/src/unix.rs @@ -17,14 +17,14 @@ * along with espanso. If not, see . */ -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}; @@ -143,4 +143,4 @@ impl IPCClient for UnixIPCClient { Ok(()) } -} \ No newline at end of file +} diff --git a/espanso-ipc/src/util.rs b/espanso-ipc/src/util.rs index 80adad1..0c5753c 100644 --- a/espanso-ipc/src/util.rs +++ b/espanso-ipc/src/util.rs @@ -44,4 +44,4 @@ pub fn read_line(stream: R) -> Result> { } else { Ok(Some(String::from_utf8(buffer)?)) } -} \ No newline at end of file +} diff --git a/espanso-ipc/src/windows.rs b/espanso-ipc/src/windows.rs index 833f243..99e8eaf 100644 --- a/espanso-ipc/src/windows.rs +++ b/espanso-ipc/src/windows.rs @@ -17,16 +17,14 @@ * along with espanso. If not, see . */ +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;