Table of Contents

Struct Page<T>

Namespace
Trellis
Assembly
Trellis.Core.dll

A single page of items from a paginated collection together with the cursors needed to fetch adjacent pages. The canonical Trellis primitive for server-driven pagination.

public readonly record struct Page<T> : IEquatable<Page<T>>

Type Parameters

T

The item type.

Implements
Inherited Members
Extension Methods

Remarks

Wire shape: Trellis projects Page<T> to 200 OK with a JSON body envelope and a co-emitted Link header (RFC 8288). See Trellis.Asp.HttpResponseExtensions.ToHttpResponse for the Result<Page<T>> overload.

Why not 206 Partial Content? RFC 9110 ยง14 was designed for byte-range transfer of a single octet stream; collection pagination has no IANA-registered range unit and no proxy/CDN ecosystem support. Use Page<T> for collections; reserve 206 for actual byte-range GETs.

Cap visibility: RequestedLimit records what the client asked for and AppliedLimit records what the server actually used. WasCapped makes server-side clamping observable without the client having to compare counts.

Constructors

Page(IReadOnlyList<T>, Cursor?, Cursor?, int, int)

Constructs a validated page. Use Empty<T>(int, int) for empty pages.

public Page(IReadOnlyList<T> Items, Cursor? Next, Cursor? Previous, int RequestedLimit, int AppliedLimit)

Parameters

Items IReadOnlyList<T>
Next Cursor?
Previous Cursor?
RequestedLimit int
AppliedLimit int

Exceptions

ArgumentNullException

Items is null.

ArgumentOutOfRangeException

A limit is non-positive, or AppliedLimit exceeds RequestedLimit.

Properties

AppliedLimit

The limit the server actually applied (after server-side cap).

public int AppliedLimit { get; }

Property Value

int

DeliveredCount

The number of items actually returned in this page.

public int DeliveredCount { get; }

Property Value

int

Remarks

Defensive against default(Page<T>): returns 0 when Items is null.

Items

The items returned for this page (never null when constructed via the public ctor).

public IReadOnlyList<T> Items { get; }

Property Value

IReadOnlyList<T>

Next

Cursor for the next page, or null when this is the last page.

public Cursor? Next { get; }

Property Value

Cursor?

Previous

Cursor for the previous page, or null when this is the first page (or the source doesn't support reverse).

public Cursor? Previous { get; }

Property Value

Cursor?

RequestedLimit

The limit the client requested.

public int RequestedLimit { get; }

Property Value

int

WasCapped

True when the server applied a smaller limit than the client requested.

public bool WasCapped { get; }

Property Value

bool