1mod budget;
4mod link;
5mod numbered;
6mod offset;
7mod opaque;
8
9pub use budget::{
10 MAX_SNAPSHOT_ID_BYTES, PaginationBudget, PaginationLimits, PaginationProgress, SnapshotId,
11 SnapshotPolicy,
12};
13pub use link::{ProviderLinkBinding, ProviderLinkExecutionError, ValidatedProviderLink};
14pub use numbered::{NumberedPageBoundary, NumberedPageMetadata, NumberedPagination, PageNumber};
15pub use offset::{OffsetPageBoundary, OffsetPageMetadata, OffsetPagination};
16pub use opaque::{
17 CursorDigest, CursorHistory, MAX_OPAQUE_STATE_BYTES, PaginationCursor, PaginationMarker,
18};
19
20#[derive(Clone, Copy, Debug, Eq, PartialEq)]
22pub enum PaginationError {
23 ZeroLimit,
25 StateLimitTooLarge,
27 PageZero,
29 PageSizeZero,
31 InvalidPreviousPage,
33 InvalidNextPage,
35 InvalidLastPage,
37 UnexpectedPosition,
39 EmptyPageWithContinuation,
41 InvalidEntryCount,
43 PageSizeChanged,
45 TraversalChanged,
47 RequestBudgetExceeded,
49 ItemBudgetExceeded,
51 SnapshotRequired,
53 SnapshotIdEmpty,
55 SnapshotIdTooLong,
57 SnapshotForbidden,
59 SnapshotChanged,
61 Complete,
63 MissingState,
65 StateTooLong,
67 OutputTooSmall,
69 HistoryBudgetExceeded,
71 CursorCycle,
73 CursorDigestCollision,
75 CursorDigestChanged,
77 InvalidProviderLink,
79 ProviderLinkSchemeChanged,
81 ProviderLinkAuthorityChanged,
83 ProviderLinkUserinfo,
85 ProviderLinkFragment,
87 ProviderLinkPathChanged,
89 ProviderLinkMethodChanged,
91 ProviderLinkOperationChanged,
93}
94
95impl_static_error!(PaginationError,
96 Self::ZeroLimit => "pagination limits must be nonzero",
97 Self::StateLimitTooLarge => "opaque pagination state limit exceeds the hard limit",
98 Self::PageZero => "page number must be nonzero",
99 Self::PageSizeZero => "page size must be nonzero",
100 Self::InvalidPreviousPage => "previous-page metadata is invalid",
101 Self::InvalidNextPage => "next-page metadata is invalid",
102 Self::InvalidLastPage => "last-page metadata is invalid",
103 Self::UnexpectedPosition => "response position differs from the requested position",
104 Self::EmptyPageWithContinuation => "nonterminal response page is empty",
105 Self::InvalidEntryCount => "response entry count is invalid",
106 Self::PageSizeChanged => "response page size changed during traversal",
107 Self::TraversalChanged => "pagination metadata changed during traversal",
108 Self::RequestBudgetExceeded => "pagination request budget was exceeded",
109 Self::ItemBudgetExceeded => "pagination item budget was exceeded",
110 Self::SnapshotRequired => "provider snapshot identifier is required",
111 Self::SnapshotIdEmpty => "provider snapshot identifier is empty",
112 Self::SnapshotIdTooLong => "provider snapshot identifier exceeds the length limit",
113 Self::SnapshotForbidden => "provider snapshot identifier is forbidden",
114 Self::SnapshotChanged => "provider snapshot identifier changed during traversal",
115 Self::Complete => "pagination traversal is complete",
116 Self::MissingState => "opaque pagination state is missing",
117 Self::StateTooLong => "opaque pagination state exceeds the selected limit",
118 Self::OutputTooSmall => "pagination state output is too small",
119 Self::HistoryBudgetExceeded => "cursor history budget was exceeded",
120 Self::CursorCycle => "pagination cursor cycle was detected",
121 Self::CursorDigestCollision => "pagination cursor digest collision was detected",
122 Self::CursorDigestChanged => "pagination cursor digest changed for the same state",
123 Self::InvalidProviderLink => "provider pagination link is invalid",
124 Self::ProviderLinkSchemeChanged => "provider pagination link changed scheme",
125 Self::ProviderLinkAuthorityChanged => "provider pagination link changed authority",
126 Self::ProviderLinkUserinfo => "provider pagination link contains user information",
127 Self::ProviderLinkFragment => "provider pagination link contains a fragment",
128 Self::ProviderLinkPathChanged => "provider pagination link changed operation path",
129 Self::ProviderLinkMethodChanged => "provider pagination link changed HTTP method",
130 Self::ProviderLinkOperationChanged => "provider pagination link changed operation",
131);
132
133#[cfg(test)]
134mod tests;