pub fn new() -> Result<Enet, InitializationError> {
        match ENET_STATUS.compare_and_swap(ENET_UNINITIALIZED, ENET_INITIALIZED, Ordering::SeqCst) {
            ENET_UNINITIALIZED => (),
            ENET_INITIALIZED => return Err(InitializationError::AlreadyInitialized),
            ENET_DEINITIALIZED => return Err(InitializationError::AlreadyDeinitialized),
            u => panic!(
                "enet-rs internal error; unexpected value in ENET_STATUS (new): {}",
                u
            ),
        };

        let r = unsafe { enet_initialize() };

        if r != 0 {
            return Err(InitializationError::Error(r));
        }

        Ok(Enet {
            keep_alive: Arc::new(EnetKeepAlive),
        })
    }
/// Initializes ENet and returns a handle to the top-level functionality, in the form of an `Enet`-instance.
Initializes ENet and returns a handle to the top-level functionality, in the form of an `Enet`-instance.
Initializes ENet and returns a handle to the top - level functionality in the form of an ` Enet ` - instance .
pub fn new() -> Result<Enet, InitializationError> {
        match ENET_STATUS.compare_and_swap(ENET_UNINITIALIZED, ENET_INITIALIZED, Ordering::SeqCst) {
            ENET_UNINITIALIZED => (),
            ENET_INITIALIZED => return Err(InitializationError::AlreadyInitialized),
            ENET_DEINITIALIZED => return Err(InitializationError::AlreadyDeinitialized),
            u => panic!(
                "enet-rs internal error; unexpected value in ENET_STATUS (new): {}",
                u
            ),
        };
        let r = unsafe { enet_initialize() };
        if r != 0 {
            return Err(InitializationError::Error(r));
        }
        Ok(Enet {
            keep_alive: Arc::new(EnetKeepAlive),
        })
    }
pub fn new ( ) -> Result < Enet , InitializationError > { match ENET_STATUS . compare_and_swap ( ENET_UNINITIALIZED , ENET_INITIALIZED , Ordering :: SeqCst ) { ENET_UNINITIALIZED => ( ) , ENET_INITIALIZED => return Err ( InitializationError :: AlreadyInitialized ) , ENET_DEINITIALIZED => return Err ( InitializationError :: AlreadyDeinitialized ) , u => panic ! ( " " u ) , } ; let r = unsafe { enet_initialize ( ) } ; if r != 0 { return Err ( InitializationError :: Error ( r ) ) ; } Ok ( Enet { keep_alive : Arc :: new ( EnetKeepAlive ) , } ) }
Initializes ENet and returns a handle to the top-level functionality, in the form of an `Enet`-instance.
Initializes ENet and returns a handle to the top - level functionality in the form of an ` Enet ` - instance .