From f3122cc55af676c6e1b3f04008e6b455b8b83f5b Mon Sep 17 00:00:00 2001 From: Till Hoeppner Date: Fri, 26 Jun 2015 21:51:02 +0200 Subject: Use SharedClient instead of OwnedClient in Streams --- src/client.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/client.rs b/src/client.rs index e548a83..2ea2e13 100644 --- a/src/client.rs +++ b/src/client.rs @@ -212,21 +212,21 @@ pub struct SharedClient { } impl SharedClient { - pub fn messages(&self) -> Stream<(Arc>, Message)> { - let cl = self.client.clone(); + pub fn messages(&self) -> Stream<(SharedClient, Message)> { + let cl = SharedClient { client: self.client.clone() }; self.client.lock().unwrap().messages() .map(move |m| (cl.clone(), m)) } - /*pub fn events(&self) -> Stream<(Message, Event)> { - self.client.lock().unwrap().messages().filter_map(|msg| match Command::from_message(&msg) { - Some(m) => Some((msg, Event::Command(m.clone()))), + pub fn events(&self) -> Stream<(SharedClient, Message, Arc>)> { + self.messages().filter_map(|(cl, msg)| match Command::from_message(&msg) { + Some(m) => Some((cl, msg, Arc::new(Event::Command(m.clone())))), None => match Reply::from_message(&msg) { - Some(r) => Some((msg, Event::Reply(r))), + Some(r) => Some((cl, msg, Arc::new(Event::Reply(r)))), None => None } }) - }*/ + } // pub fn commands(&self) -> Stream { // self.messages().filter_map(|msg| Command::from_message(&msg).map(|c| c.to_static())) -- cgit v1.2.3