pub fn new_socket(&self, address: SocketAddr) -> Result<EmulatedSocket> {
        match self.network.borrow_mut().entry(address) {
            Entry::Occupied(_) => Err(std::io::Error::new(
                std::io::ErrorKind::AddrInUse,
                "Cannot bind to address",
            )),
            Entry::Vacant(entry) => {
                entry.insert(Default::default());
                Ok(EmulatedSocket {
                    network: self.network.clone(),
                    address,
                    conditioner: Default::default(),
                })
            }
        }
    }
/// Creates an emulated socket by binding to an address.
/// If other socket already was bound to this address, error will be returned instead.

Creates an emulated socket by binding to an address.
If other socket already was bound to this address, error will be returned instead.
Creates an emulated socket by binding to an address . If other socket already was bound to this address error will be returned instead .
pub fn new_socket(&self, address: SocketAddr) -> Result<EmulatedSocket> {
        match self.network.borrow_mut().entry(address) {
            Entry::Occupied(_) => Err(std::io::Error::new(
                std::io::ErrorKind::AddrInUse,
                "Cannot bind to address",
            )),
            Entry::Vacant(entry) => {
                entry.insert(Default::default());
                Ok(EmulatedSocket {
                    network: self.network.clone(),
                    address,
                    conditioner: Default::default(),
                })
            }
        }
    }
pub fn new_socket ( & self , address : SocketAddr ) -> Result < EmulatedSocket > { match self . network . borrow_mut ( ) . entry ( address ) { Entry :: Occupied ( _ ) => Err ( std :: io :: Error :: new ( std :: io :: ErrorKind :: AddrInUse , " " , ) ) , Entry :: Vacant ( entry ) => { entry . insert ( Default :: default ( ) ) ; Ok ( EmulatedSocket { network : self . network . clone ( ) , address , conditioner : Default :: default ( ) , } ) } } }
Creates an emulated socket by binding to an address.
Creates an emulated socket by binding to an address .
&self
address
SocketAddr
&self
address
SocketAddr