Documentation Index
Fetch the complete documentation index at: https://mintlify.com/FarlandsModdingTeam/TerbinProyect/llms.txt
Use this file to discover all available pages before exploring further.
BufferWriter and BufferReader are the low-level building blocks that Serialineitor delegates to internally. Use them directly when you need precise control over a pre-allocated Span<byte> or ReadOnlySpan<byte> without the auto-growing overhead of the builder.
BufferWriter (Static)
BufferWriter writes into an existing Span<byte> and advances a ref-passed offset integer.
Methods
Writes a single unmanaged value at
pOffset and advances pOffset by sizeof(T).Writes a
ThreeQuartersInt (3-byte) length header followed by the raw element bytes. Throws ArgumentOutOfRangeException if the buffer is too small.AddStruct<T>(Span<byte> pBuffer, ref int pOffset, T pStruct) where T : struct, IStructSerializable
void
Writes an
IStructSerializable struct by calling pStruct.WriteTo().Writes an unmanaged value into a
byte[], auto-resizing the array (doubling + sizeof(T)) if needed. Use when you do not know the required capacity upfront.BufferWriterExtension
Extension methods onSpan<byte> in two flavors: slicing (the span advances automatically, returning a BufferErrorCode) and offset-based (the span is unchanged, you track position via ref int).
Slicing variants (advance the span)
These returnBufferErrorCode and slice the span forward after each write:
Offset-based variants (span stays intact)
These delegate toBufferWriter static methods and do not slice the span:
BufferReader (Static)
BufferReader reads from a ReadOnlySpan<byte> or byte[] and advances a ref offset.
Methods
Reads a single unmanaged value at
pOffset and advances pOffset by sizeof(T).Reads a
ThreeQuartersInt length header, then reads that many bytes and casts them to T[]. Advances pOffset past both the header and the data.GetStruct<T>(ReadOnlySpan<byte> pBuffer, ref int pOffset, T pStruct) where T : struct, IStructSerializable
T
Deserializes a struct by calling
Serialineitor.DeserializeStructRaw on a slice starting at pOffset, then advances pOffset by pStruct.GetSize().BufferReaderExtension
Extension methods onReadOnlySpan<byte> mirroring the writer’s two flavors.
Slicing variants (advance the span)
Offset-based variants (span stays intact)
Comparison: Slicing vs Offset-Based
The slicing variants are used extensively in Terbin service handlers. See the
ReadOnlySpan<byte> reader = pParameters pattern throughout ServicePlugins.cs, ServiceInstances.cs, etc.