Class Payload
A single-owner buffer rented from ArrayPool<T>. Dispose returns the backing array to the pool exactly once. Treat Memory as read-only after the buffer has been handed off (it is mutable only to support the receive fill path and the IMemoryOwner<T> contract).
public sealed class Payload : IMemoryOwner<byte>, IDisposable
- Inheritance
-
Payload
- Implements
- Inherited Members
Properties
Empty
Shared empty payload. Wraps Empty<T>(); Dispose() is a guaranteed no-op so the singleton stays reusable.
public static Payload Empty { get; }
Property Value
Length
The number of usable bytes in the payload.
public int Length { get; }
Property Value
Memory
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; }
Property Value
Span
A read-only view of the usable region of the rented buffer.
public ReadOnlySpan<byte> Span { get; }
Property Value
Methods
Dispose()
Returns the backing array to the pool. Idempotent and safe to call on Empty.
public void Dispose()
Rent(int)
Rents a payload of at least length bytes. A zero length returns the
shared Empty singleton.
public static Payload Rent(int length)
Parameters
lengthint