DotNext by Roman Sakno

<PackageReference Include="DotNext" Version="3.2.1" />

 BufferHelpers

public static class BufferHelpers
Represents helper methods to work with various buffer representations.
public static string BuildString(this ArrayBufferWriter<char> writer)

Constructs the string from the buffer.

public static ReadOnlySequence<T> Concat<T>(this ReadOnlyMemory<T> first, ReadOnlyMemory<T> second)

Converts two memory blocks to ReadOnlySequence<T> data type.

public static void CopyTo<T>(this ref ReadOnlySequence source, Span<T> destination, out int writtenCount)

Copies the contents from the source sequence into a destination span.

public static ref T GetReference<T>(ref MemoryOwner owner)

Gets managed pointer to the first element in the rented memory block.

Reads the value of blittable type from the raw bytes represents by memory block.

public static double ReadDouble(this ref SpanReader reader, bool isLittleEndian)

Decodes double-precision floating-point number.

public static short ReadInt16(this ref SpanReader reader, bool isLittleEndian)

Decodes 16-bit signed integer.

public static int ReadInt32(this ref SpanReader reader, bool isLittleEndian)

Decodes 32-bit signed integer.

public static long ReadInt64(this ref SpanReader reader, bool isLittleEndian)

Decodes 64-bit signed integer.

public static float ReadSingle(this ref SpanReader reader, bool isLittleEndian)

Decodes single-precision floating-point number.

public static ushort ReadUInt16(this ref SpanReader reader, bool isLittleEndian)

Decodes 16-bit unsigned integer.

public static uint ReadUInt32(this ref SpanReader reader, bool isLittleEndian)

Decodes 32-bit unsigned integer.

public static ulong ReadUInt64(this ref SpanReader reader, bool isLittleEndian)

Decodes 64-bit unsigned integer.

public static void ReleaseAll<T>(this ref MemoryOwner owner) where T : IDisposable

Releases all resources encapsulated by the container.

public static void Resize<T>(this ref MemoryOwner owner, int newLength, bool exactSize = true, MemoryAllocator<T> allocator = null)

Resizes the buffer.

public static ReadOnlySequence<T> ToReadOnlySequence<T>(this IEnumerable<ReadOnlyMemory<T>> chunks)

Converts the sequence of memory blocks to ReadOnlySequence<T> data type.

public static bool TryRead<T>(this ref SpanReader reader, out T result) where T : ValueType modreq(System.Runtime.InteropServices.UnmanagedType)

Reads the value of blittable type from the raw bytes represents by memory block.

public static bool TryWrite<T>(this ref SpanWriter writer, ref T value) where T : ValueType modreq(System.Runtime.InteropServices.UnmanagedType)

Writes value of blittable type as bytes to the underlying memory block.

public static void Write(this ref BufferWriterSlim writer, StringBuilder input)

Writes the contents of string builder to the buffer.

public static void Write<T>(this IBufferWriter<T> writer, T value)

Writes single element to the buffer.

public static void Write<T>(this IBufferWriter<T> writer, ref ReadOnlySequence value)

Writes the sequence of elements to the buffer.

public static void Write(this IBufferWriter<char> writer, StringBuilder input)

Writes the contents of string builder to the buffer.

public static void Write<T>(this ref SpanWriter writer, ref T value) where T : ValueType modreq(System.Runtime.InteropServices.UnmanagedType)

Writes value of blittable type as bytes to the underlying memory block.

public static void Write(this ref SpanWriter writer, StringBuilder input)

Writes the contents of string builder to the buffer.

public static void WriteDouble(this ref BufferWriterSlim builder, double value, bool isLittleEndian)

Encodes doubke-precision floating-point number as bytes.

public static void WriteDouble(this ref SpanWriter writer, double value, bool isLittleEndian)

Writes double-precision floating-point number to the block of memory.

public static void WriteInt16(this ref BufferWriterSlim builder, short value, bool isLittleEndian)

Encodes 16-bit signed integer as bytes.

public static void WriteInt16(this ref SpanWriter writer, short value, bool isLittleEndian)

Writes 16-bit signed integer to the block of memory.

public static void WriteInt32(this ref BufferWriterSlim builder, int value, bool isLittleEndian)

Encodes 32-bit signed integer as bytes.

public static void WriteInt32(this ref SpanWriter writer, int value, bool isLittleEndian)

Writes 32-bit signed integer to the block of memory.

public static void WriteInt64(this ref BufferWriterSlim builder, long value, bool isLittleEndian)

Encodes 64-bit signed integer as bytes.

public static void WriteInt64(this ref SpanWriter writer, long value, bool isLittleEndian)

Writes 64-bit signed integer to the block of memory.

public static void WriteSingle(this ref BufferWriterSlim builder, float value, bool isLittleEndian)

Encodes single-precision floating-point number as bytes.

public static void WriteSingle(this ref SpanWriter writer, float value, bool isLittleEndian)

Writes single-precision floating-point number to the block of memory.

public static void WriteUInt16(this ref BufferWriterSlim builder, ushort value, bool isLittleEndian)

Encodes 16-bit unsigned integer as bytes.

public static void WriteUInt16(this ref SpanWriter writer, ushort value, bool isLittleEndian)

Writes 16-bit unsigned integer to the block of memory.

public static void WriteUInt32(this ref BufferWriterSlim builder, uint value, bool isLittleEndian)

Encodes 32-bit unsigned integer as bytes.

public static void WriteUInt32(this ref SpanWriter writer, uint value, bool isLittleEndian)

Writes 32-bit unsigned integer to the block of memory.

public static void WriteUInt64(this ref BufferWriterSlim builder, ulong value, bool isLittleEndian)

Encodes 64-bit unsigned integer as bytes.

public static void WriteUInt64(this ref SpanWriter writer, ulong value, bool isLittleEndian)

Writes 64-bit unsigned integer to the block of memory.