Skip to content

Commit 0392993

Browse files
committed
Remove readhelp.rs, and deal with unused warnings
As of Rust 1.6.0 `read_exact` is in the standard library so we don't need our own anymore!
1 parent b260c10 commit 0392993

File tree

3 files changed

+5
-21
lines changed

3 files changed

+5
-21
lines changed

examples/command_loop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use i3ipc::I3Connection;
77
fn main() {
88
println!("Executes i3 commands in a loop. Enter \"q\" at any time to quit.");
99
let mut connection = I3Connection::connect().ok().expect("failed to connect");
10-
let mut stdin = io::stdin();
10+
let stdin = io::stdin();
1111
let mut stdout = io::stdout();
1212
loop {
1313
print!(">>> ");

src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,8 @@ use std::str::FromStr;
2727

2828
use unix_socket::UnixStream;
2929
use serde_json as json;
30-
use event::Event;
3130
use byteorder::{ReadBytesExt, WriteBytesExt, LittleEndian};
3231

33-
mod readhelp;
3432
mod common;
3533
pub mod reply;
3634
pub mod event;
@@ -139,7 +137,8 @@ impl I3Funcs for UnixStream {
139137

140138
/// returns a tuple of (message type, payload)
141139
fn receive_i3_message(&mut self) -> io::Result<(u32, String)> {
142-
let magic_data = try!(readhelp::read_exact(self, 6));
140+
let mut magic_data = [0_u8; 6];
141+
try!(self.read_exact(&mut magic_data));
143142
let magic_string = String::from_utf8_lossy(&magic_data);
144143
if magic_string != "i3-ipc" {
145144
let error_text = format!("unexpected magic string: expected 'i3-ipc' but got {}",
@@ -148,7 +147,8 @@ impl I3Funcs for UnixStream {
148147
}
149148
let payload_len = try!(self.read_u32::<LittleEndian>());
150149
let message_type = try!(self.read_u32::<LittleEndian>());
151-
let payload_data = try!(readhelp::read_exact(self, payload_len as usize));
150+
let mut payload_data = vec![0_u8 ; payload_len as usize];
151+
try!(self.read_exact(&mut payload_data[..]));
152152
let payload_string = String::from_utf8_lossy(&payload_data).into_owned();
153153
Ok((message_type, payload_string))
154154
}

src/readhelp.rs

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)