Table of Contents

Struct BinarySpanReader

Namespace
Vintagestory.API.Datastructures
Assembly
VintagestoryAPI.dll
public ref struct BinarySpanReader
Inherited Members
Extension Methods

Constructors

BinarySpanReader(ReadOnlySpan<byte>)

public BinarySpanReader(ReadOnlySpan<byte> data)

Parameters

data ReadOnlySpan<byte>

Properties

CurrentOffset

public readonly int CurrentOffset { get; }

Property Value

int

RemainingBytes

public readonly ReadOnlySpan<byte> RemainingBytes { get; }

Property Value

ReadOnlySpan<byte>

Methods

ReadBoolean()

public bool ReadBoolean()

Returns

bool

Remarks

Equivalent to ReadBoolean().
This reads a whole byte to read one bool. If you have multiple bools you want to transport consider packing them into a large enough integer type.
A byte already has enough space to transport 8 bools by packing them into its bits.
This exists for convenience and parity with BinaryReader.

ReadByte()

public byte ReadByte()

Returns

byte

ReadBytes(int)

public ReadOnlySpan<byte> ReadBytes(int count)

Parameters

count int

Returns

ReadOnlySpan<byte>

ReadDouble()

public double ReadDouble()

Returns

double

ReadFloat16BE()

public Half ReadFloat16BE()

Returns

Half

ReadFloat16LE()

public Half ReadFloat16LE()

Returns

Half

Remarks

Equivalent to ReadHalf()

ReadFloat32BE()

public float ReadFloat32BE()

Returns

float

ReadFloat32LE()

public float ReadFloat32LE()

Returns

float

Remarks

Equivalent to ReadSingle()

ReadFloat64BE()

public double ReadFloat64BE()

Returns

double

ReadFloat64LE()

public double ReadFloat64LE()

Returns

double

Remarks

Equivalent to ReadDouble()

ReadHalf()

public Half ReadHalf()

Returns

Half

ReadInt16()

public short ReadInt16()

Returns

short

ReadInt16BE()

public short ReadInt16BE()

Returns

short

ReadInt16LE()

public short ReadInt16LE()

Returns

short

Remarks

Equivalent to ReadInt16()

ReadInt32()

public int ReadInt32()

Returns

int

ReadInt32BE()

public int ReadInt32BE()

Returns

int

ReadInt32LE()

public int ReadInt32LE()

Returns

int

Remarks

Equivalent to ReadInt32()

ReadInt64()

public long ReadInt64()

Returns

long

ReadInt64BE()

public long ReadInt64BE()

Returns

long

ReadInt64LE()

public long ReadInt64LE()

Returns

long

Remarks

Equivalent to ReadInt64()

ReadInt8BE()

public sbyte ReadInt8BE()

Returns

sbyte

Remarks

Identical to ReadUInt8LE(). There are two methods for name parity with other operations.

ReadInt8LE()

public sbyte ReadInt8LE()

Returns

sbyte

Remarks

Equivalent to ReadByte().
Identical to ReadInt8BE(). There are two methods for name parity with other operations.

ReadSByte()

public sbyte ReadSByte()

Returns

sbyte

ReadSingle()

public float ReadSingle()

Returns

float

ReadString(int)

public string ReadString(int byteLengthLimit = 2147483647)

Parameters

byteLengthLimit int

Since this method allocates memory form potentially untrusted data you can restrict the byte size of said allocation. Should the data contain a length for the string larger than this parameters value a FormatException is thrown.

Returns

string

Remarks

Equivalent to ReadString().

ReadUInt16()

public ushort ReadUInt16()

Returns

ushort

ReadUInt16BE()

public ushort ReadUInt16BE()

Returns

ushort

ReadUInt16LE()

public ushort ReadUInt16LE()

Returns

ushort

Remarks

Equivalent to ReadUInt16()

ReadUInt32()

public uint ReadUInt32()

Returns

uint

ReadUInt32BE()

public uint ReadUInt32BE()

Returns

uint

ReadUInt32LE()

public uint ReadUInt32LE()

Returns

uint

Remarks

Equivalent to ReadUInt32()

ReadUInt64()

public ulong ReadUInt64()

Returns

ulong

ReadUInt64BE()

public ulong ReadUInt64BE()

Returns

ulong

ReadUInt64LE()

public ulong ReadUInt64LE()

Returns

ulong

Remarks

Equivalent to ReadUInt64()

ReadUInt8BE()

public byte ReadUInt8BE()

Returns

byte

Remarks

Identical to ReadUInt8LE(). There are two methods for name parity with other operations.

ReadUInt8LE()

public byte ReadUInt8LE()

Returns

byte

Remarks

Equivalent to ReadSByte().
Identical to ReadUInt8BE(). There are two methods for name parity with other operations.

SkipBytes(int)

public void SkipBytes(int count)

Parameters

count int