Skip to content

Instantly share code, notes, and snippets.

@tailhook
Created December 10, 2016 01:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tailhook/a6b4322b2c28c85451514e23d56eab92 to your computer and use it in GitHub Desktop.
Save tailhook/a6b4322b2c28c85451514e23d56eab92 to your computer and use it in GitHub Desktop.
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