summaryrefslogtreecommitdiffstats
path: root/src/channel.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/channel.rs')
-rw-r--r--src/channel.rs16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/channel.rs b/src/channel.rs
index 85c1d410..e9996f9c 100644
--- a/src/channel.rs
+++ b/src/channel.rs
@@ -6,8 +6,7 @@
use std::io;
use std::sync::mpsc::TryRecvError;
-use futures::{Poll, Async};
-use futures::stream::Stream;
+use futures::{Poll, Async, Sink, AsyncSink, StartSend, Stream};
use mio::channel;
use reactor::{Handle, PollEvented};
@@ -82,6 +81,19 @@ impl<T> Sender<T> {
}
}
+impl<T> Sink for Sender<T> {
+ type SinkItem = T;
+ type SinkError = io::Error;
+
+ fn start_send(&mut self, t: T) -> StartSend<T, io::Error> {
+ Sender::send(self, t).map(|()| AsyncSink::Ready)
+ }
+
+ fn poll_complete(&mut self) -> Poll<(), io::Error> {
+ Ok(().into())
+ }
+}
+
impl<T> Clone for Sender<T> {
fn clone(&self) -> Sender<T> {
Sender { tx: self.tx.clone() }