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
GetSize(int)
public static int GetSize(int v)
Parameters
v
int
Returns
GetSize(float)
public static int GetSize(float v)
Parameters
v
float
Returns
GetSize(string)
public static int GetSize(string s)
Parameters
s
string
Returns
GetSize(ushort)
public static int GetSize(ushort v)
Parameters
v
ushort
Returns
GetSize(Vec2i)
public static int GetSize(Vec2i val)
Parameters
val
Vec2i
Returns
Write(FastMemoryStream, int, bool)
public static void Write(FastMemoryStream stream, int field, bool val)
Parameters
stream
FastMemoryStreamfield
intval
bool
Write(FastMemoryStream, int, byte[])
public static void Write(FastMemoryStream stream, int field, byte[] val)
Parameters
stream
FastMemoryStreamfield
intval
byte[]
Write(FastMemoryStream, int, IDictionary<string, byte[]>)
public static void Write(FastMemoryStream stream, int field, IDictionary<string, byte[]> dict)
Parameters
stream
FastMemoryStreamfield
intdict
IDictionary<string, byte[]>
Write(FastMemoryStream, int, IDictionary<Vec2i, float>)
public static void Write(FastMemoryStream stream, int field, IDictionary<Vec2i, float> dict)
Parameters
stream
FastMemoryStreamfield
intdict
IDictionary<Vec2i, float>
Write(FastMemoryStream, int, IEnumerable<byte[]>)
public static void Write(FastMemoryStream stream, int field, IEnumerable<byte[]> collection)
Parameters
stream
FastMemoryStreamfield
intcollection
IEnumerable<byte[]>
Write(FastMemoryStream, int, IEnumerable<int>)
public static void Write(FastMemoryStream stream, int field, IEnumerable<int> collection)
Parameters
stream
FastMemoryStreamfield
intcollection
IEnumerable<int>
Write(FastMemoryStream, int, IEnumerable<string>)
public static void Write(FastMemoryStream stream, int field, IEnumerable<string> collection)
Parameters
stream
FastMemoryStreamfield
intcollection
IEnumerable<string>
Write(FastMemoryStream, int, IEnumerable<ushort>)
public static void Write(FastMemoryStream stream, int field, IEnumerable<ushort> collection)
Parameters
stream
FastMemoryStreamfield
intcollection
IEnumerable<ushort>
Write(FastMemoryStream, int, IEnumerable<BlockPos>)
public static void Write(FastMemoryStream stream, int field, IEnumerable<BlockPos> collection)
Parameters
stream
FastMemoryStreamfield
intcollection
IEnumerable<BlockPos>
Write(FastMemoryStream, int, IEnumerable<Vec4i>)
public static void Write(FastMemoryStream stream, int field, IEnumerable<Vec4i> collection)
Parameters
stream
FastMemoryStreamfield
intcollection
IEnumerable<Vec4i>
Write(FastMemoryStream, int, int)
public static void Write(FastMemoryStream stream, int field, int val)
Parameters
stream
FastMemoryStreamfield
intval
int
Write(FastMemoryStream, int, float)
public static void Write(FastMemoryStream stream, int field, float val)
Parameters
stream
FastMemoryStreamfield
intval
float
Write(FastMemoryStream, int, string)
public static void Write(FastMemoryStream stream, int field, string s)
Parameters
stream
FastMemoryStreamfield
ints
string
Write(FastMemoryStream, int, FastMemoryStream)
public static void Write(FastMemoryStream stream, int field, FastMemoryStream val)
Parameters
stream
FastMemoryStreamfield
intval
FastMemoryStream
Write(FastMemoryStream, int, BlockPos)
public static void Write(FastMemoryStream stream, int field, BlockPos val)
Parameters
stream
FastMemoryStreamfield
intval
BlockPos
Write(FastMemoryStream, int, Vec2i)
public static void Write(FastMemoryStream stream, int field, Vec2i val)
Parameters
stream
FastMemoryStreamfield
intval
Vec2i
Write(FastMemoryStream, int, Vec4i)
public static void Write(FastMemoryStream stream, int field, Vec4i val)
Parameters
stream
FastMemoryStreamfield
intval
Vec4i
WritePacked(FastMemoryStream, int, IEnumerable<int>)
public static void WritePacked(FastMemoryStream stream, int field, IEnumerable<int> collection)
Parameters
stream
FastMemoryStreamfield
intcollection
IEnumerable<int>
WritePacked(FastMemoryStream, int, IEnumerable<ushort>)
public static void WritePacked(FastMemoryStream stream, int field, IEnumerable<ushort> collection)
Parameters
stream
FastMemoryStreamfield
intcollection
IEnumerable<ushort>
WriteTagLengthDelim(FastMemoryStream, int, int)
public static void WriteTagLengthDelim(FastMemoryStream stream, int field, int length)
Parameters
stream
FastMemoryStreamfield
intlength
int