// If the insertion fails for some reason, we give it back to the caller.
If the insertion fails for some reason, we give it back to the caller.
If the insertion fails for some reason we give it back to the caller .
pub async fn insert(&self, peer_id: PeerId, peer_info: PeerInfo) -> Result<(), InsertionFailure> {
        if let Err(e) = self.accepts(&peer_id, &peer_info).await {
            Err(InsertionFailure(peer_id, peer_info, e))
        } else {
            // Since we already checked that such a `peer_id` is not yet present, the returned value is always `None`.
            let _ = self
                .0
                .write()
                .await
                .insert(peer_id, (peer_info, PeerState::disconnected()));
            Ok(())
        }
    }
pub async fn insert ( & self , peer_id : PeerId , peer_info : PeerInfo ) -> Result < ( ) , InsertionFailure > { if let Err ( e ) = self . accepts ( & peer_id , & peer_info ) . await { Err ( InsertionFailure ( peer_id , peer_info , e ) ) } else { // Since we already checked that such a `peer_id` is not yet present, the returned value is always `None`. let _ = self . 0 . write ( ) . await . insert ( peer_id , ( peer_info , PeerState :: disconnected ( ) ) ) ; Ok ( ( ) ) } }
If the insertion fails for some reason, we give it back to the caller.
If the insertion fails for some reason we give it back to the caller .
&self
peer_id
PeerId
peer_info
PeerInfo