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
TThe item type.
- Implements
-
IEquatable<Page<T>>
- 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
ItemsIReadOnlyList<T>NextCursor?PreviousCursor?RequestedLimitintAppliedLimitint
Exceptions
- ArgumentNullException
Itemsisnull.- ArgumentOutOfRangeException
A limit is non-positive, or
AppliedLimitexceedsRequestedLimit.
Properties
AppliedLimit
The limit the server actually applied (after server-side cap).
public int AppliedLimit { get; }
Property Value
DeliveredCount
The number of items actually returned in this page.
public int DeliveredCount { get; }
Property Value
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
Next
Cursor for the next page, or null when this is the last page.
public Cursor? Next { get; }
Property Value
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
RequestedLimit
The limit the client requested.
public int RequestedLimit { get; }
Property Value
WasCapped
True when the server applied a smaller limit than the client requested.
public bool WasCapped { get; }