Created
December 10, 2016 01:34
-
-
Save tailhook/a6b4322b2c28c85451514e23d56eab92 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait Service<T, R>: Sink<SinkItem=(T, Sender<R>)> { | |
fn call(&mut self, req: T) -> impl Future { | |
let (tx, rx) = oneshot(); | |
match self.start_send((req, tx)) { | |
Ok(Async::NotReady(e)) => { return Err(busy()).into_future() } | |
Ok(Async::Ready) => { return rx; } | |
Err(e) => { return Err(e).into_future() } | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment