Unity.Netcode.BufferSerializer-1
Two-way serializer wrapping FastBufferReader or FastBufferWriter.
Implemented as a ref struct for two reasons:
- The BufferSerializer cannot outlive the FBR/FBW it wraps or using it will cause a crash
- The BufferSerializer must always be passed by reference and can't be copied
Ref structs help enforce both of those rules: they can't ref live the stack context in which they were created, and they're always passed by reference no matter what.
BufferSerializer doesn't wrapp FastBufferReader or FastBufferWriter directly because it can't. ref structs can't implement interfaces, and in order to be able to have two different implementations with the same interface (which allows us to avoid an "if(IsReader)" on every call), the thing directly wrapping the struct has to implement an interface. So IReaderWriter exists as the interface, which is implemented by a normal struct, while the ref struct wraps the normal one to enforce the two above requirements. (Allowing direct access to the IReaderWriter struct would allow dangerous things to happen because the struct's lifetime could outlive the Reader/Writer's.)
#
Inherited MembersSystem.ValueType.Equals(System.Object)
System.ValueType.GetHashCode()
System.ValueType.ToString()
System.Object.Equals(System.Object, System.Object)
System.Object.GetType()
System.Object.ReferenceEquals(System.Object, System.Object)
#
Syntax#
Type ParametersName | Description |
---|---|
TReaderWriter | The implementation struct |
#
Properties#
IsReaderCheck if the contained implementation is a reader
#
Declaration#
Property ValueType | Description |
---|---|
System.Boolean |
#
IsWriterCheck if the contained implementation is a writer
#
Declaration#
Property ValueType | Description |
---|---|
System.Boolean |
#
Methods#
GetFastBufferReader()Retrieves the FastBufferReader instance. Only valid if IsReader = true, throws InvalidOperationException otherwise.
#
Declaration#
ReturnsType | Description |
---|---|
FastBufferReader | Reader instance |
#
GetFastBufferWriter()Retrieves the FastBufferWriter instance. Only valid if IsWriter = true, throws InvalidOperationException otherwise.
#
Declaration#
ReturnsType | Description |
---|---|
FastBufferWriter | Writer instance |
#
PreCheck(Int32)#
Declaration#
ParametersType | Name | Description |
---|---|---|
System.Int32 | amount |
#
ReturnsType | Description |
---|---|
System.Boolean |
#
SerializeNetworkSerializable\<T>(ref T)#
Declaration#
ParametersType | Name | Description |
---|---|---|
T | value |
#
Type ParametersName | Description |
---|---|
T |
#
SerializeValue(ref Color)#
Declaration#
ParametersType | Name | Description |
---|---|---|
Color | value |
#
SerializeValue(ref Color[])#
Declaration#
ParametersType | Name | Description |
---|---|---|
Color[] | value |
#
SerializeValue(ref Color32)#
Declaration#
ParametersType | Name | Description |
---|---|---|
Color32 | value |
#
SerializeValue(ref Color32[])#
Declaration#
ParametersType | Name | Description |
---|---|---|
Color32[] | value |
#
SerializeValue(ref Quaternion)#
Declaration#
ParametersType | Name | Description |
---|---|---|
Quaternion | value |
#
SerializeValue(ref Quaternion[])#
Declaration#
ParametersType | Name | Description |
---|---|---|
Quaternion[] | value |
#
SerializeValue(ref Ray)#
Declaration#
ParametersType | Name | Description |
---|---|---|
Ray | value |
#
SerializeValue(ref Ray[])#
Declaration#
ParametersType | Name | Description |
---|---|---|
Ray[] | value |
#
SerializeValue(ref Ray2D)#
Declaration#
ParametersType | Name | Description |
---|---|---|
Ray2D | value |
#
SerializeValue(ref Ray2D[])#
Declaration#
ParametersType | Name | Description |
---|---|---|
Ray2D[] | value |
#
SerializeValue(ref Byte)#
Declaration#
ParametersType | Name | Description |
---|---|---|
System.Byte | value |
#
SerializeValue(ref String, Boolean)#
Declaration#
ParametersType | Name | Description |
---|---|---|
System.String | s | |
System.Boolean | oneByteChars |
#
SerializeValue(ref Vector2)#
Declaration#
ParametersType | Name | Description |
---|---|---|
Vector2 | value |
#
SerializeValue(ref Vector2[])#
Declaration#
ParametersType | Name | Description |
---|---|---|
Vector2[] | value |
#
SerializeValue(ref Vector3)#
Declaration#
ParametersType | Name | Description |
---|---|---|
Vector3 | value |
#
SerializeValue(ref Vector3[])#
Declaration#
ParametersType | Name | Description |
---|---|---|
Vector3[] | value |
#
SerializeValue(ref Vector4)#
Declaration#
ParametersType | Name | Description |
---|---|---|
Vector4 | value |
#
SerializeValue(ref Vector4[])#
Declaration#
ParametersType | Name | Description |
---|---|---|
Vector4[] | value |
#
SerializeValue\<T>(ref T, FastBufferWriter.ForEnums)#
Declaration#
ParametersType | Name | Description |
---|---|---|
T | value | |
FastBufferWriter.ForEnums | unused |
#
Type ParametersName | Description |
---|---|
T |
#
SerializeValue\<T>(ref T, FastBufferWriter.ForNetworkSerializable)#
Declaration#
ParametersType | Name | Description |
---|---|---|
T | value | |
FastBufferWriter.ForNetworkSerializable | unused |
#
Type ParametersName | Description |
---|---|
T |
#
SerializeValue\<T>(ref T, FastBufferWriter.ForPrimitives)#
Declaration#
ParametersType | Name | Description |
---|---|---|
T | value | |
FastBufferWriter.ForPrimitives | unused |
#
Type ParametersName | Description |
---|---|
T |
#
SerializeValue\<T>(ref T, FastBufferWriter.ForStructs)#
Declaration#
ParametersType | Name | Description |
---|---|---|
T | value | |
FastBufferWriter.ForStructs | unused |
#
Type ParametersName | Description |
---|---|
T |
#
SerializeValue\<T>(ref T[], FastBufferWriter.ForEnums)#
Declaration#
ParametersType | Name | Description |
---|---|---|
T[] | value | |
FastBufferWriter.ForEnums | unused |
#
Type ParametersName | Description |
---|---|
T |
#
SerializeValue\<T>(ref T[], FastBufferWriter.ForNetworkSerializable)#
Declaration#
ParametersType | Name | Description |
---|---|---|
T[] | value | |
FastBufferWriter.ForNetworkSerializable | unused |
#
Type ParametersName | Description |
---|---|
T |
#
SerializeValue\<T>(ref T[], FastBufferWriter.ForPrimitives)#
Declaration#
ParametersType | Name | Description |
---|---|---|
T[] | value | |
FastBufferWriter.ForPrimitives | unused |
#
Type ParametersName | Description |
---|---|
T |
#
SerializeValue\<T>(ref T[], FastBufferWriter.ForStructs)#
Declaration#
ParametersType | Name | Description |
---|---|---|
T[] | value | |
FastBufferWriter.ForStructs | unused |
#
Type ParametersName | Description |
---|---|
T |
#
SerializeValuePreChecked(ref Color)#
Declaration#
ParametersType | Name | Description |
---|---|---|
Color | value |
#
SerializeValuePreChecked(ref Color[])#
Declaration#
ParametersType | Name | Description |
---|---|---|
Color[] | value |
#
SerializeValuePreChecked(ref Color32)#
Declaration#
ParametersType | Name | Description |
---|---|---|
Color32 | value |
#
SerializeValuePreChecked(ref Color32[])#
Declaration#
ParametersType | Name | Description |
---|---|---|
Color32[] | value |
#
SerializeValuePreChecked(ref Quaternion)#
Declaration#
ParametersType | Name | Description |
---|---|---|
Quaternion | value |
#
SerializeValuePreChecked(ref Quaternion[])#
Declaration#
ParametersType | Name | Description |
---|---|---|
Quaternion[] | value |
#
SerializeValuePreChecked(ref Ray)#
Declaration#
ParametersType | Name | Description |
---|---|---|
Ray | value |
#
SerializeValuePreChecked(ref Ray[])#
Declaration#
ParametersType | Name | Description |
---|---|---|
Ray[] | value |
#
SerializeValuePreChecked(ref Ray2D)#
Declaration#
ParametersType | Name | Description |
---|---|---|
Ray2D | value |
#
SerializeValuePreChecked(ref Ray2D[])#
Declaration#
ParametersType | Name | Description |
---|---|---|
Ray2D[] | value |
#
SerializeValuePreChecked(ref Byte)#
Declaration#
ParametersType | Name | Description |
---|---|---|
System.Byte | value |
#
SerializeValuePreChecked(ref String, Boolean)#
Declaration#
ParametersType | Name | Description |
---|---|---|
System.String | s | |
System.Boolean | oneByteChars |
#
SerializeValuePreChecked(ref Vector2)#
Declaration#
ParametersType | Name | Description |
---|---|---|
Vector2 | value |
#
SerializeValuePreChecked(ref Vector2[])#
Declaration#
ParametersType | Name | Description |
---|---|---|
Vector2[] | value |
#
SerializeValuePreChecked(ref Vector3)#
Declaration#
ParametersType | Name | Description |
---|---|---|
Vector3 | value |
#
SerializeValuePreChecked(ref Vector3[])#
Declaration#
ParametersType | Name | Description |
---|---|---|
Vector3[] | value |
#
SerializeValuePreChecked(ref Vector4)#
Declaration#
ParametersType | Name | Description |
---|---|---|
Vector4 | value |
#
SerializeValuePreChecked(ref Vector4[])#
Declaration#
ParametersType | Name | Description |
---|---|---|
Vector4[] | value |
#
SerializeValuePreChecked\<T>(ref T, FastBufferWriter.ForEnums)#
Declaration#
ParametersType | Name | Description |
---|---|---|
T | value | |
FastBufferWriter.ForEnums | unused |
#
Type ParametersName | Description |
---|---|
T |
#
SerializeValuePreChecked\<T>(ref T, FastBufferWriter.ForPrimitives)#
Declaration#
ParametersType | Name | Description |
---|---|---|
T | value | |
FastBufferWriter.ForPrimitives | unused |
#
Type ParametersName | Description |
---|---|
T |
#
SerializeValuePreChecked\<T>(ref T, FastBufferWriter.ForStructs)#
Declaration#
ParametersType | Name | Description |
---|---|---|
T | value | |
FastBufferWriter.ForStructs | unused |
#
Type ParametersName | Description |
---|---|
T |
#
SerializeValuePreChecked\<T>(ref T[], FastBufferWriter.ForEnums)#
Declaration#
ParametersType | Name | Description |
---|---|---|
T[] | value | |
FastBufferWriter.ForEnums | unused |
#
Type ParametersName | Description |
---|---|
T |
#
SerializeValuePreChecked\<T>(ref T[], FastBufferWriter.ForPrimitives)#
Declaration#
ParametersType | Name | Description |
---|---|---|
T[] | value | |
FastBufferWriter.ForPrimitives | unused |
#
Type ParametersName | Description |
---|---|
T |
#
SerializeValuePreChecked\<T>(ref T[], FastBufferWriter.ForStructs)#
Declaration#
ParametersType | Name | Description |
---|---|---|
T[] | value | |
FastBufferWriter.ForStructs | unused |
#
Type ParametersName | Description |
---|---|
T |