The current implementation lifts a lot of state out of existing objects into the trait; we could instead probably simply assume that paginated requests are in fact V1|V2ListRequests, and use the state from their inner query attribute. This would significantly reduce code duplication for every paginated search endpoint. Even if not all paginated requests are search requests with query attributes, we could create a separate trait for these search requests.
We also currently hand-rewrite the types to use usize (since we count pages and usize presumably felt more appropriate), however the spec specifies i64. We should change those back (maybe regenerate the types and build impls on wrapper structs like this one, or simply implement the trait sketched out above on them).
Finally, we are currently hand-cloning structs when they implement Clone - we really ought to stop doing that.
In general, the PaginationHandler should probably be thought out once more; these are just things I realized while working with it in #45 - see comments there for specific pointers.
The current implementation lifts a lot of state out of existing objects into the trait; we could instead probably simply assume that paginated requests are in fact
V1|V2ListRequests, and use the state from their innerqueryattribute. This would significantly reduce code duplication for every paginated search endpoint. Even if not all paginated requests are search requests withqueryattributes, we could create a separate trait for these search requests.We also currently hand-rewrite the types to use
usize(since we count pages andusizepresumably felt more appropriate), however the spec specifiesi64. We should change those back (maybe regenerate the types and buildimpls on wrapper structs like this one, or simply implement the trait sketched out above on them).Finally, we are currently hand-cloning structs when they implement
Clone- we really ought to stop doing that.In general, the
PaginationHandlershould probably be thought out once more; these are just things I realized while working with it in #45 - see comments there for specific pointers.