pub async fn query(&self, addr: &SocketAddr) -> Option<Result> {
        let mut rx = match self.map.lock().await.entry(*addr) {
            Entry::Occupied(entry) => entry.get().subscribe(),
            Entry::Vacant(entry) => {
                let (tx, _) = broadcast::channel(1);
                let _ = entry.insert(tx);
                return None;
            }
        };

        if let Ok(result) = rx.recv().await {
            Some(result)
        } else {
            // NOTE: this branch cannot realistically happen, because we never drop the `Sender`
            // without sending through it first and we also take it out of the map before doing so
            // which means it's not possible to create more subscription on it after the send.
            // This, however, is not statically provable so we still need to nominally handle this
            // branch. We return `LocallyClosed` which seems like it would be the right error to
            // return if this situation was actually possible (it isn't) as it would signal the
            // caller to either abandon the connect or try to repeat it.
            Some(Err(quinn::ConnectionError::LocallyClosed.into()))
        }
    }
// Query if there already is a connect attempt to the given address.
// If this is the first connect attempt, it returns `None` and we should proceed with
// establishing the connection and then call `complete` with the result.
// For any subsequent connect attempt this returns `Some` with the result of that attempt.
Query if there already is a connect attempt to the given address.
If this is the first connect attempt, it returns `None` and we should proceed with
establishing the connection and then call `complete` with the result.
For any subsequent connect attempt this returns `Some` with the result of that attempt.
Query if there already is a connect attempt to the given address . If this is the first connect attempt it returns ` None ` and we should proceed with establishing the connection and then call ` complete ` with the result . For any subsequent connect attempt this returns ` Some ` with the result of that attempt .
pub async fn query(&self, addr: &SocketAddr) -> Option<Result> {
        let mut rx = match self.map.lock().await.entry(*addr) {
            Entry::Occupied(entry) => entry.get().subscribe(),
            Entry::Vacant(entry) => {
                let (tx, _) = broadcast::channel(1);
                let _ = entry.insert(tx);
                return None;
            }
        };
        if let Ok(result) = rx.recv().await {
            Some(result)
        } else {
            // NOTE: this branch cannot realistically happen, because we never drop the `Sender`
            // without sending through it first and we also take it out of the map before doing so
            // which means it's not possible to create more subscription on it after the send.
            // This, however, is not statically provable so we still need to nominally handle this
            // branch. We return `LocallyClosed` which seems like it would be the right error to
            // return if this situation was actually possible (it isn't) as it would signal the
            // caller to either abandon the connect or try to repeat it.
            Some(Err(quinn::ConnectionError::LocallyClosed.into()))
        }
    }
pub async fn query ( & self , addr : & SocketAddr ) -> Option < Result > { let mut rx = match self . map . lock ( ) . await . entry ( * addr ) { Entry :: Occupied ( entry ) => entry . get ( ) . subscribe ( ) , Entry :: Vacant ( entry ) => { let ( tx , _ ) = broadcast :: channel ( 1 ) ; let _ = entry . insert ( tx ) ; return None ; } } ; if let Ok ( result ) = rx . recv ( ) . await { Some ( result ) } else { // NOTE: this branch cannot realistically happen, because we never drop the `Sender` // without sending through it first and we also take it out of the map before doing so // which means it's not possible to create more subscription on it after the send. // This, however, is not statically provable so we still need to nominally handle this // branch. We return `LocallyClosed` which seems like it would be the right error to // return if this situation was actually possible (it isn't) as it would signal the // caller to either abandon the connect or try to repeat it. Some ( Err ( quinn :: ConnectionError :: LocallyClosed . into ( ) ) ) } }
Query if there already is a connect attempt to the given address.
Query if there already is a connect attempt to the given address .
&self
addr
&SocketAddr
&self
addr
&SocketAddr