error handling cleanup
This commit is contained in:
parent
4a1ecdee35
commit
2995f6e48b
@ -29,9 +29,7 @@ impl<'payload> I3msg<'payload> {
|
|||||||
IoSlice::new(self.payload.as_bytes()),
|
IoSlice::new(self.payload.as_bytes()),
|
||||||
];
|
];
|
||||||
|
|
||||||
match self.buffer.write_vectored(bufs) {
|
self.buffer.write_vectored(bufs)?;
|
||||||
Ok(_) => return Ok(self.buffer.to_owned()),
|
Ok(self.buffer.to_owned())
|
||||||
Err(e) => return Err(e),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -17,10 +17,8 @@ pub struct Sway {
|
|||||||
|
|
||||||
impl Sway {
|
impl Sway {
|
||||||
pub fn new(socket: &str) -> Result<Sway> {
|
pub fn new(socket: &str) -> Result<Sway> {
|
||||||
match UnixStream::connect(socket) {
|
let stream = UnixStream::connect(socket)?;
|
||||||
Ok(stream) => return Ok(Sway{stream}),
|
Ok(Sway{stream})
|
||||||
Err(e) => return Err(e),
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Runs the payload as sway commands
|
/// Runs the payload as sway commands
|
||||||
@ -126,7 +124,7 @@ impl Sway {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::Sway;
|
use crate::Sway;
|
||||||
use crate::i3msg::*;
|
use crate::i3msg::I3msg;
|
||||||
use crate::ipc::*;
|
use crate::ipc::*;
|
||||||
|
|
||||||
fn sway_ipc() -> Sway {
|
fn sway_ipc() -> Sway {
|
||||||
|
Loading…
Reference in New Issue
Block a user