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....) Open in GitHub
public static class FastSerializer
- Inheritance
-
FastSerializer
- Inherited Members
Methods
GetSize(byte[])
public static int GetSize(byte[] val)
Parameters
valbyte[]
Returns
GetSize(int)
public static int GetSize(int v)
Parameters
vint
Returns
GetSize(float)
public static int GetSize(float v)
Parameters
vfloat
Returns
GetSize(string)
public static int GetSize(string s)
Parameters
sstring
Returns
GetSize(ushort)
public static int GetSize(ushort v)
Parameters
vushort
Returns
GetSize(Vec2i)
public static int GetSize(Vec2i val)
Parameters
valVec2i
Returns
Write(FastMemoryStream, int, bool)
public static void Write(FastMemoryStream stream, int field, bool val)
Parameters
streamFastMemoryStreamfieldintvalbool
Write(FastMemoryStream, int, byte[])
public static void Write(FastMemoryStream stream, int field, byte[] val)
Parameters
streamFastMemoryStreamfieldintvalbyte[]
Write(FastMemoryStream, int, IDictionary<string, byte[]>)
public static void Write(FastMemoryStream stream, int field, IDictionary<string, byte[]> dict)
Parameters
streamFastMemoryStreamfieldintdictIDictionary<string, byte[]>
Write(FastMemoryStream, int, IDictionary<Vec2i, float>)
public static void Write(FastMemoryStream stream, int field, IDictionary<Vec2i, float> dict)
Parameters
streamFastMemoryStreamfieldintdictIDictionary<Vec2i, float>
Write(FastMemoryStream, int, IEnumerable<byte[]>)
public static void Write(FastMemoryStream stream, int field, IEnumerable<byte[]> collection)
Parameters
streamFastMemoryStreamfieldintcollectionIEnumerable<byte[]>
Write(FastMemoryStream, int, IEnumerable<int>)
public static void Write(FastMemoryStream stream, int field, IEnumerable<int> collection)
Parameters
streamFastMemoryStreamfieldintcollectionIEnumerable<int>
Write(FastMemoryStream, int, IEnumerable<string>)
public static void Write(FastMemoryStream stream, int field, IEnumerable<string> collection)
Parameters
streamFastMemoryStreamfieldintcollectionIEnumerable<string>
Write(FastMemoryStream, int, IEnumerable<ushort>)
public static void Write(FastMemoryStream stream, int field, IEnumerable<ushort> collection)
Parameters
streamFastMemoryStreamfieldintcollectionIEnumerable<ushort>
Write(FastMemoryStream, int, IEnumerable<BlockPos>)
public static void Write(FastMemoryStream stream, int field, IEnumerable<BlockPos> collection)
Parameters
streamFastMemoryStreamfieldintcollectionIEnumerable<BlockPos>
Write(FastMemoryStream, int, IEnumerable<Vec4i>)
public static void Write(FastMemoryStream stream, int field, IEnumerable<Vec4i> collection)
Parameters
streamFastMemoryStreamfieldintcollectionIEnumerable<Vec4i>
Write(FastMemoryStream, int, int)
public static void Write(FastMemoryStream stream, int field, int val)
Parameters
streamFastMemoryStreamfieldintvalint
Write(FastMemoryStream, int, float)
public static void Write(FastMemoryStream stream, int field, float val)
Parameters
streamFastMemoryStreamfieldintvalfloat
Write(FastMemoryStream, int, string)
public static void Write(FastMemoryStream stream, int field, string s)
Parameters
streamFastMemoryStreamfieldintsstring
Write(FastMemoryStream, int, FastMemoryStream)
public static void Write(FastMemoryStream stream, int field, FastMemoryStream val)
Parameters
streamFastMemoryStreamfieldintvalFastMemoryStream
Write(FastMemoryStream, int, BlockPos)
public static void Write(FastMemoryStream stream, int field, BlockPos val)
Parameters
streamFastMemoryStreamfieldintvalBlockPos
Write(FastMemoryStream, int, Vec2i)
public static void Write(FastMemoryStream stream, int field, Vec2i val)
Parameters
streamFastMemoryStreamfieldintvalVec2i
Write(FastMemoryStream, int, Vec4i)
public static void Write(FastMemoryStream stream, int field, Vec4i val)
Parameters
streamFastMemoryStreamfieldintvalVec4i
WritePacked(FastMemoryStream, int, IEnumerable<int>)
public static void WritePacked(FastMemoryStream stream, int field, IEnumerable<int> collection)
Parameters
streamFastMemoryStreamfieldintcollectionIEnumerable<int>
WritePacked(FastMemoryStream, int, IEnumerable<ushort>)
public static void WritePacked(FastMemoryStream stream, int field, IEnumerable<ushort> collection)
Parameters
streamFastMemoryStreamfieldintcollectionIEnumerable<ushort>
WriteTagLengthDelim(FastMemoryStream, int, int)
public static void WriteTagLengthDelim(FastMemoryStream stream, int field, int length)
Parameters
streamFastMemoryStreamfieldintlengthint