Table of Contents

Class FastSerializer

Namespace
Vintagestory.API.Util
Assembly
VintagestoryAPI.dll

A faster implementation of a ProtoBuf serializer.
Note 1: for int and ushort and other primitives/structs, the default value of 0 will not be written (because the read value will be 0 anyhow, so not writing the 0 value makes no difference to what the reader eventually reads): except in arrays and other simple collections such as List, where 0 values will be written, so that the reader reads out all subsequent values in the array with the correct indexing
Note 2: for reference types including string, if the value is null then nothing will be written. A read collection may therefore be shorter than the written collection, if the written collection included null values: be careful serializing arrays of reference types, if necessary replace null values with something else prior to serialization. For convenience, one special exception here is arrays or lists of string: if a null string is in the array, FastSerializer will instead automatically write an empty string "". (We don't do that for other reference types because it is not necessarily clear what the default non-null value should be....)

public static class FastSerializer
Inheritance
FastSerializer
Inherited Members

Methods

GetSize(byte[])

public static int GetSize(byte[] val)

Parameters

val byte[]

Returns

int

GetSize(int)

public static int GetSize(int v)

Parameters

v int

Returns

int

GetSize(float)

public static int GetSize(float v)

Parameters

v float

Returns

int

GetSize(string)

public static int GetSize(string s)

Parameters

s string

Returns

int

GetSize(ushort)

public static int GetSize(ushort v)

Parameters

v ushort

Returns

int

GetSize(Vec2i)

public static int GetSize(Vec2i val)

Parameters

val Vec2i

Returns

int

Write(FastMemoryStream, int, bool)

public static void Write(FastMemoryStream stream, int field, bool val)

Parameters

stream FastMemoryStream
field int
val bool

Write(FastMemoryStream, int, byte[])

public static void Write(FastMemoryStream stream, int field, byte[] val)

Parameters

stream FastMemoryStream
field int
val byte[]

Write(FastMemoryStream, int, IDictionary<string, byte[]>)

public static void Write(FastMemoryStream stream, int field, IDictionary<string, byte[]> dict)

Parameters

stream FastMemoryStream
field int
dict IDictionary<string, byte[]>

Write(FastMemoryStream, int, IDictionary<Vec2i, float>)

public static void Write(FastMemoryStream stream, int field, IDictionary<Vec2i, float> dict)

Parameters

stream FastMemoryStream
field int
dict IDictionary<Vec2i, float>

Write(FastMemoryStream, int, IEnumerable<byte[]>)

public static void Write(FastMemoryStream stream, int field, IEnumerable<byte[]> collection)

Parameters

stream FastMemoryStream
field int
collection IEnumerable<byte[]>

Write(FastMemoryStream, int, IEnumerable<int>)

public static void Write(FastMemoryStream stream, int field, IEnumerable<int> collection)

Parameters

stream FastMemoryStream
field int
collection IEnumerable<int>

Write(FastMemoryStream, int, IEnumerable<string>)

public static void Write(FastMemoryStream stream, int field, IEnumerable<string> collection)

Parameters

stream FastMemoryStream
field int
collection IEnumerable<string>

Write(FastMemoryStream, int, IEnumerable<ushort>)

public static void Write(FastMemoryStream stream, int field, IEnumerable<ushort> collection)

Parameters

stream FastMemoryStream
field int
collection IEnumerable<ushort>

Write(FastMemoryStream, int, IEnumerable<BlockPos>)

public static void Write(FastMemoryStream stream, int field, IEnumerable<BlockPos> collection)

Parameters

stream FastMemoryStream
field int
collection IEnumerable<BlockPos>

Write(FastMemoryStream, int, IEnumerable<Vec4i>)

public static void Write(FastMemoryStream stream, int field, IEnumerable<Vec4i> collection)

Parameters

stream FastMemoryStream
field int
collection IEnumerable<Vec4i>

Write(FastMemoryStream, int, int)

public static void Write(FastMemoryStream stream, int field, int val)

Parameters

stream FastMemoryStream
field int
val int

Write(FastMemoryStream, int, float)

public static void Write(FastMemoryStream stream, int field, float val)

Parameters

stream FastMemoryStream
field int
val float

Write(FastMemoryStream, int, string)

public static void Write(FastMemoryStream stream, int field, string s)

Parameters

stream FastMemoryStream
field int
s string

Write(FastMemoryStream, int, FastMemoryStream)

public static void Write(FastMemoryStream stream, int field, FastMemoryStream val)

Parameters

stream FastMemoryStream
field int
val FastMemoryStream

Write(FastMemoryStream, int, BlockPos)

public static void Write(FastMemoryStream stream, int field, BlockPos val)

Parameters

stream FastMemoryStream
field int
val BlockPos

Write(FastMemoryStream, int, Vec2i)

public static void Write(FastMemoryStream stream, int field, Vec2i val)

Parameters

stream FastMemoryStream
field int
val Vec2i

Write(FastMemoryStream, int, Vec4i)

public static void Write(FastMemoryStream stream, int field, Vec4i val)

Parameters

stream FastMemoryStream
field int
val Vec4i

WritePacked(FastMemoryStream, int, IEnumerable<int>)

public static void WritePacked(FastMemoryStream stream, int field, IEnumerable<int> collection)

Parameters

stream FastMemoryStream
field int
collection IEnumerable<int>

WritePacked(FastMemoryStream, int, IEnumerable<ushort>)

public static void WritePacked(FastMemoryStream stream, int field, IEnumerable<ushort> collection)

Parameters

stream FastMemoryStream
field int
collection IEnumerable<ushort>

WriteTagLengthDelim(FastMemoryStream, int, int)

public static void WriteTagLengthDelim(FastMemoryStream stream, int field, int length)

Parameters

stream FastMemoryStream
field int
length int