1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
#![allow(non_snake_case)] extern crate libc; #[macro_use] extern crate unsafe_unions; pub mod address; pub mod host; pub mod protocol; pub mod list; pub mod packet; pub mod peer; pub mod socket; use libc::*; use host::ENetHost; use packet::ENetPacket; use list::{ENetList, ENetListNode}; use peer::{ENET_PEER_RELIABLE_WINDOWS, ENetPeer}; use protocol::ENetProtocol; pub type ENetVersion = uint32_t; pub type ENetChecksumCallback = extern fn(buffers: *const ENetBuffer, bufferCount: size_t) -> uint32_t; pub type ENetInterceptCallback = extern fn(host: *mut ENetHost, event: *mut ENetEvent); pub const ENET_HOST_ANY : uint32_t = 0; #[repr(C)] pub struct ENetCallbacks { pub free: extern fn(memory: *mut c_void), pub malloc: extern fn(size: size_t) -> *mut c_void, pub no_memory: extern fn(), } #[repr(C)] pub struct ENetBuffer { pub data: *mut c_void, pub dataLength: size_t, } #[repr(C)] pub struct ENetCompressor { pub context: *mut c_void, pub compress: extern fn(context: *mut c_void, inBuffers: *const ENetBuffer, inBufferCount: size_t, inLimit: size_t, outData: *mut uint8_t, outLimit: size_t) -> size_t, pub decompress: extern fn(context: *mut c_void, inData: *const uint8_t, inLimit: size_t, outData: *mut uint8_t, outLimit: size_t) -> size_t, pub destroy: extern fn(context: *mut c_void), } #[repr(C)] pub struct ENetEvent { pub _type: ENetEventType, pub peer: *mut ENetPeer, pub channelID: uint8_t, pub data: uint32_t, pub packet: *mut ENetPacket, } #[repr(C)] pub enum ENetEventType { ENET_EVENT_TYPE_NONE = 0, ENET_EVENT_TYPE_CONNECT = 1, ENET_EVENT_TYPE_DISCONNECT = 2, ENET_EVENT_TYPE_RECEIVE = 3, } #[repr(C)] pub struct ENetChannel { pub outgoingReliableSequenceNumber: uint16_t, pub outgoingUnrelianleSequenceNumber: uint16_t, pub usedReliableWindows: uint16_t, pub reliableWindows: [uint16_t; ENET_PEER_RELIABLE_WINDOWS], pub incomingReliableSequenceNumber: uint16_t, pub incomingUnreliableSequenceNumber: uint16_t, pub incomingReliableCommands: ENetList, pub incomingUnreliableCommands: ENetList, } #[repr(C)] pub struct ENetAcknowledgement { pub achnowledgementList: ENetListNode, pub sentTime: uint32_t, pub command: ENetProtocol, } #[repr(C)] pub struct ENetIncomingCommand { pub incomingCommandsList: ENetListNode, pub reliableSequenceNumber: uint16_t, pub unreliableSequenceNumber: uint16_t, pub command: ENetProtocol, pub fragmentCount: uint32_t, pub fragmentsRemaining: uint32_t, pub fragments: *mut uint32_t, pub packet: *mut ENetPacket, } #[repr(C)] pub struct ENetOutgoingCommand { pub outgoingCommandList: ENetListNode, pub reliableSequenceNumber: uint16_t, pub unreliableSequenceNumber: uint16_t, pub sentTime: uint32_t, pub roundTripTimeout: uint32_t, pub roundTripTimeoutLimit: uint32_t, pub fragmentOffset: uint32_t, pub fragmentLength: uint16_t, pub sendAttempts: uint16_t, pub command: ENetProtocol, pub packet: *mut ENetPacket, } extern { pub fn enet_deinitialize(); pub fn enet_initialize() -> c_int; pub fn enet_initialize_with_callbacks(version: ENetVersion, ) -> c_int; pub fn enet_linked_version() -> ENetVersion; }