Skip to content

Instantly share code, notes, and snippets.

@tailhook
Created Dec 10, 2016
Embed
What would you like to do?
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