[][src]Struct dropshot::PaginationParams

pub struct PaginationParams<ScanParams, PageSelector> where
    ScanParams: DeserializeOwned,
    PageSelector: DeserializeOwned + Serialize
{ pub page: WhichPage<ScanParams, PageSelector>, // some fields omitted }

Querystring parameters provided by clients when scanning a paginated collection

To build an API endpoint that paginates results, you have your handler function accept a Query<PaginationParams<ScanParams, PageSelector>> and return a ResultsPage. You define your own ScanParams and PageSelector types.

ScanParams describes the set of querystring parameters that your endpoint accepts for the first request of the scan (typically: filters and sort options). This must be deserializable from a querystring.

PageSelector describes the information your endpoint needs for requests after the first one. Typically this would include an id of some sort for the last item on the previous page as well as any parameters related to filtering or sorting so that your function can apply those, too. The entire PageSelector will be serialized to an opaque string and included in the ResultsPage. The client is expected to provide this string as the "page_token" querystring parameter in the subsequent request. PageSelector must implement both Deserialize and Serialize. (Unlike ScanParams, PageSelector will not be deserialized directly from the querystring.)

There are several complete, documented examples in dropshot/examples.

NOTE: Your choices of ScanParams and PageSelector determine the querystring parameters accepted by your endpoint and the structure of the page token, respectively. Both of these are part of your API's public interface, though the page token won't appear in the OpenAPI spec. Be careful when designing these structures to consider what you might want to support in the future.

Fields

page: WhichPage<ScanParams, PageSelector>

Specifies whether this is the first request in a scan or a subsequent request, as well as the parameters provided

See WhichPage for details. Note that this field is flattened by serde, so you have to look at the variants of WhichPage to see what query parameters are actually processed here.

Trait Implementations

impl<ScanParams: Debug, PageSelector: Debug> Debug for PaginationParams<ScanParams, PageSelector> where
    ScanParams: DeserializeOwned,
    PageSelector: DeserializeOwned + Serialize
[src]

impl<'de, ScanParams, PageSelector> Deserialize<'de> for PaginationParams<ScanParams, PageSelector> where
    ScanParams: DeserializeOwned,
    PageSelector: DeserializeOwned + Serialize
[src]

impl<ScanParams: JsonSchema, PageSelector: JsonSchema> JsonSchema for PaginationParams<ScanParams, PageSelector> where
    ScanParams: DeserializeOwned,
    PageSelector: DeserializeOwned + Serialize
[src]

Auto Trait Implementations

impl<ScanParams, PageSelector> RefUnwindSafe for PaginationParams<ScanParams, PageSelector> where
    PageSelector: RefUnwindSafe,
    ScanParams: RefUnwindSafe

impl<ScanParams, PageSelector> Send for PaginationParams<ScanParams, PageSelector> where
    PageSelector: Send,
    ScanParams: Send

impl<ScanParams, PageSelector> Sync for PaginationParams<ScanParams, PageSelector> where
    PageSelector: Sync,
    ScanParams: Sync

impl<ScanParams, PageSelector> Unpin for PaginationParams<ScanParams, PageSelector> where
    PageSelector: Unpin,
    ScanParams: Unpin

impl<ScanParams, PageSelector> UnwindSafe for PaginationParams<ScanParams, PageSelector> where
    PageSelector: UnwindSafe,
    ScanParams: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> SendSyncUnwindSafe for T where
    T: Send + Sync + UnwindSafe + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,