diff --git a/src/lib.rs b/src/lib.rs index 5ba1afd..e72d09a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,13 +4,14 @@ mod ipc; use std::os::unix::net::UnixStream; use std::io::prelude::*; -use std::io::Result; use serde::de::DeserializeOwned; use i3msg::I3msg; use types::*; use ipc::*; +type Result = std::result::Result>; + pub struct Sway { stream: UnixStream, } @@ -107,17 +108,11 @@ impl Sway { let mut buffer = [0; 25000]; let n = self.stream.read(&mut buffer)?; - match serde_json::from_slice::(&buffer[14..n]) { - Ok(result) => Ok(result), - Err(e) => Err(e.into()), - } + Ok(serde_json::from_slice::(&buffer[14..n])?) } fn parse_events(&mut self, events: Vec<&str>) -> Result { - match serde_json::to_string(&events) { - Ok(json) => Ok(json), - Err(e) => Err(e.into()), - } + Ok(serde_json::to_string(&events)?) } }