This is an automated email from the ASF dual-hosted git repository. msciabarra pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-runtime-rust.git
commit fccd2ed18db465301462878e261f2e195ae1ba98 Author: Bruce Adams <b...@us.ibm.com> AuthorDate: Thu Mar 7 08:05:15 2019 -0500 Format code, fix typos, quiet clippy Ran these two commands: - cargo fmt - cargo clippy --- rust1.32/src/action_loop/src/main.rs | 37 ++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/rust1.32/src/action_loop/src/main.rs b/rust1.32/src/action_loop/src/main.rs index e4e143d..ea6da96 100644 --- a/rust1.32/src/action_loop/src/main.rs +++ b/rust1.32/src/action_loop/src/main.rs @@ -1,32 +1,33 @@ -extern crate serde_json; extern crate actions; extern crate libc; +extern crate serde_json; +use actions::main as actionMain; +use serde_json::{Error, Value}; +use std::collections::HashMap; use std::env; -use std::io::{self, Write, stdout, stderr}; use std::fs::File; +use std::io::{self, stderr, stdout, Write}; use std::os::unix::io::FromRawFd; -use std::collections::HashMap; -use serde_json::{Value, Error}; -use actions::main as actionMain; fn main() { - let mut fd3 = unsafe { File::from_raw_fd(3)}; + let mut fd3 = unsafe { File::from_raw_fd(3) }; loop { let mut buffer = String::new(); io::stdin().read_line(&mut buffer).unwrap(); - let parsed_input:Result<HashMap<String,Value>,Error> = serde_json::from_str(&buffer); - let mut payload:HashMap<String, Value> = HashMap::new(); + let parsed_input: Result<HashMap<String, Value>, Error> = serde_json::from_str(&buffer); + let mut payload: HashMap<String, Value> = HashMap::new(); match parsed_input { Ok(n) => { for (key, val) in n { if key == "value" { - let mut unparsed_payload:Result<HashMap<String,Value>,Error> = serde_json::from_value(val); + let mut unparsed_payload: Result<HashMap<String, Value>, Error> = + serde_json::from_value(val); match unparsed_payload { Ok(value) => payload = value, Err(err) => { eprintln!("Error parsing value json: {}", err); - continue + continue; } } } else { @@ -34,15 +35,19 @@ fn main() { } } } - Err(e) =>{ + Err(e) => { eprintln!("Error: {}", e); - continue + continue; } } - - match serde_json::to_string(&actionMain(payload)){ - Ok(result) => { write!(&mut fd3, "{}\n", result).expect("Error writting on fd3");} - Err(err) => { eprintln!("Error parsing resul value json: {}", err);} + + match serde_json::to_string(&actionMain(payload)) { + Ok(result) => { + writeln!(&mut fd3, "{}", result).expect("Error writing on fd3"); + } + Err(err) => { + eprintln!("Error formatting result value json: {}", err); + } } stdout().flush().expect("Error flushing stdout"); stderr().flush().expect("Error flushing stderr");