namespace FastArena.Network.Packets
{
    internal static class PacketParser
    {
        internal static PacketType ReadHeader(byte[] data)
        {
            var h = StructBinaryConverter.ReadStruct<PacketHeader>(data);
            return h.magic == PacketHeader.MAGIC_CONST ? h.type : PacketType.Invalid;
        }

        internal static T ReadPacket<T>(byte[] data) where T : unmanaged
        {
            return StructBinaryConverter.ReadStruct<T>(data);
        }
    }
}