Skip to content

Class Payload

Namespace: DotBoxD.Services.Buffers
Assembly: DotBoxD.Services.dll

A single-owner buffer rented from System.Buffers.ArrayPool. Dispose returns the backing array to the pool exactly once. Treat DotBoxD.Services.Buffers.Payload.Memory as read-only after the buffer has been handed off (it is mutable only to support the receive fill path and the System.Buffers.IMemoryOwner contract).

public sealed class Payload : IMemoryOwner<byte>, IDisposable

objectPayload

IMemoryOwner<byte>, IDisposable

object.Equals(object), object.Equals(object, object), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object, object), object.ToString()

Shared empty payload. Wraps System.Array.Empty; DotBoxD.Services.Buffers.Payload.Dispose is a guaranteed no-op so the singleton stays reusable.

public static Payload Empty { get; }

Payload

The number of usable bytes in the payload.

public int Length { get; }

int

The usable region of the rented buffer. Mutable to support the receive fill path; treat as read-only once the payload has been received.

public Memory<byte> Memory { get; }

Memory<byte>

A read-only view of the usable region of the rented buffer.

public ReadOnlySpan<byte> Span { get; }

ReadOnlySpan<byte>

Returns the backing array to the pool. Idempotent and safe to call on DotBoxD.Services.Buffers.Payload.Empty.

public void Dispose()

Rents a payload of at least length bytes. A zero length returns the shared DotBoxD.Services.Buffers.Payload.Empty singleton.

public static Payload Rent(int length)

length int

Payload