diff --git a/src/main.rs b/src/main.rs index 87dc746..b3ef5e2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,8 +1,6 @@ -use fake_sftp::packet::Packet; - use fake_sftp::packet::dispatch_packet; -use std::io::{stdin, BufReader, BufWriter, Read, Write}; +use std::io::{BufWriter, Write}; use std::process::Command; fn main() { @@ -19,7 +17,7 @@ fn execute_php(command: &str) -> String { .output() .expect(""); let mut buff_stderr = BufWriter::new(std::io::stderr()); - buff_stderr.write(&output.stderr); - buff_stderr.flush(); + buff_stderr.write(&output.stderr).expect("Unable to write to stderr."); + buff_stderr.flush().expect("Unable to flush stderr."); return String::from_utf8(output.stdout).expect("Unable to parse php response"); } diff --git a/src/packet.rs b/src/packet.rs index 2184a7a..16536f2 100644 --- a/src/packet.rs +++ b/src/packet.rs @@ -31,8 +31,8 @@ pub fn dispatch_packet(packet: Packet) { }; let serialized_response = response_packet.serialize(); eprintln!("{:#?}", &serialized_response); - buff_stdout.write(&serialized_response); - buff_stdout.flush(); + buff_stdout.write(&serialized_response).expect("Unable to write to stdout."); + buff_stdout.flush().expect("Unable to flush stdout."); } } diff --git a/src/packet/header.rs b/src/packet/header.rs index 5bd5b72..532b764 100644 --- a/src/packet/header.rs +++ b/src/packet/header.rs @@ -14,7 +14,6 @@ impl PacketHeader { } } pub fn serialize(&self) -> [u8; 5] { - let serializated_data: [u8; 5] = [0; 5]; let length = self.length.to_be_bytes(); let type_packet = self.type_packet; let mut return_bytes = length.to_vec();