diff --git a/src/commands/plugin_inc.rs b/src/commands/plugin_inc.rs index 3fbcba842..55ae2c3e9 100644 --- a/src/commands/plugin_inc.rs +++ b/src/commands/plugin_inc.rs @@ -55,8 +55,6 @@ pub fn plugin_inc(args: CommandArgs) -> Result { let request_raw = serde_json::to_string(&request).unwrap(); stdin.write(format!("{}\n", request_raw).as_bytes()); - // println!("Wrote out init"); - // println!("{:?}", v); let request = JsonRpc::new("filter", v); let request_raw = serde_json::to_string(&request).unwrap(); stdin.write(format!("{}\n", request_raw).as_bytes()); diff --git a/src/plugins/inc.rs b/src/plugins/inc.rs index c7cacaae8..98d1b95f3 100644 --- a/src/plugins/inc.rs +++ b/src/plugins/inc.rs @@ -9,10 +9,10 @@ use std::io; pub struct JsonRpc { jsonrpc: String, pub method: String, - pub params: T, + pub params: Vec, } impl JsonRpc { - pub fn new>(method: U, params: T) -> Self { + pub fn new>(method: U, params: Vec) -> Self { JsonRpc { jsonrpc: "2.0".into(), method: method.into(), @@ -21,12 +21,11 @@ impl JsonRpc { } } -fn send_response(result: T) { +fn send_response(result: Vec) { let response = JsonRpc::new("response", result); let response_raw = serde_json::to_string(&response).unwrap(); println!("{}", response_raw); } - #[derive(Debug, Serialize, Deserialize)] #[serde(tag = "method")] #[allow(non_camel_case_types)] @@ -56,9 +55,9 @@ fn main() -> Result<(), Box> { inc_by = i; } _ => { - send_response(ReturnValue::Value(Value::Error(Box::new( - ShellError::string("Unrecognized type in params"), - )))); + send_response(vec![ReturnValue::Value(Value::Error( + Box::new(ShellError::string("Unrecognized type in params")), + ))]); } } } @@ -73,25 +72,25 @@ fn main() -> Result<(), Box> { ))]); } _ => { - send_response(ReturnValue::Value(Value::Error(Box::new( + send_response(vec![ReturnValue::Value(Value::Error(Box::new( ShellError::string("Unrecognized type in stream"), - )))); + )))]); } }, Ok(NuCommand::quit) => { break; } Err(_) => { - send_response(ReturnValue::Value(Value::Error(Box::new( + send_response(vec![ReturnValue::Value(Value::Error(Box::new( ShellError::string("Unrecognized type in stream"), - )))); + )))]); } } } - Err(error) => { - send_response(ReturnValue::Value(Value::Error(Box::new( + Err(_) => { + send_response(vec![ReturnValue::Value(Value::Error(Box::new( ShellError::string("Unrecognized type in stream"), - )))); + )))]); } } }