aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Common/Extensions/BinaryReaderExtensions.cs
blob: dece2384cc37e6832c6bca3e26f014cef5ae881a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
using System.IO;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

namespace Ryujinx.Common
{
    public static class BinaryReaderExtensions
    {
        public static T ReadStruct<T>(this BinaryReader reader) where T : unmanaged
        {
            return MemoryMarshal.Cast<byte, T>(reader.ReadBytes(Unsafe.SizeOf<T>()))[0];
        }
    }
}