From 71e50265b94f259d078e88eccf42ebab2fb8c0a0 Mon Sep 17 00:00:00 2001 From: Alexander Andreev Date: Fri, 13 Apr 2018 21:47:16 +0300 Subject: [PATCH] impl check result response --- examples/sender.rs | 2 +- src/lib.rs | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/examples/sender.rs b/examples/sender.rs index 77efef8..d5b200d 100644 --- a/examples/sender.rs +++ b/examples/sender.rs @@ -18,7 +18,7 @@ fn main() { }; match send_one_value(&command) { - Ok(response) => println!("{:?}", response), + Ok(response) => println!("{:?} is success {} ", response, response.success()), Err(e) => println!("Error {}", e), } } diff --git a/src/lib.rs b/src/lib.rs index 17600b9..67acbea 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -166,3 +166,10 @@ pub struct Response { response: String, info: String, } + +impl Response { + /// Verifies successful if there was a request + pub fn success(&self) -> bool { + self.response == "success" + } +}