Rewrite conn module

This commit is contained in:
Joscha 2023-01-20 17:12:52 +01:00
parent 470f3455f7
commit 6916977a47
6 changed files with 328 additions and 335 deletions

View file

@ -49,6 +49,7 @@ pub struct Replies<I, R> {
pending: HashMap<I, Sender<R>>,
}
// TODO Relax bounds
impl<I: Eq + Hash, R> Replies<I, R> {
pub fn new(timeout: Duration) -> Self {
Self {
@ -57,6 +58,10 @@ impl<I: Eq + Hash, R> Replies<I, R> {
}
}
pub fn timeout(&self) -> Duration {
self.timeout
}
pub fn wait_for(&mut self, id: I) -> PendingReply<R> {
let (tx, rx) = oneshot::channel();
self.pending.insert(id, tx);