pub struct Listing<R> {
pub rows: Vec<R>,
pub total: Option<usize>,
pub cursor: Option<String>,
pub has_more: Option<bool>,
}http and validation only.Expand description
One page of a collection, on its way back to the client.
Storage returns the rows plus whatever it knows about the rest of the
collection; the handler turns that into first/prev/next/last
links. What is absent is simply not linked — a cursor-paged listing that
reports no total gets no last link rather than a wrong one.
Fields§
§rows: Vec<R>The rows on this page.
total: Option<usize>How many rows the whole collection holds, if storage counted.
Drives the last link and meta.total. Leave it None when
counting costs a second query you do not want to pay for.
cursor: Option<String>Where the next page resumes, for cursor paging.
None means this is the last page, so no next link is emitted.
Ignored under offset paging, which derives next from
has_more or, failing that, arithmetically.
has_more: Option<bool>Whether the collection continues past this page, when storage knows.
Offset paging only, and an override for the next link: without it a
full page is assumed to have a successor, so the last full page
links to an empty one. Storage that can answer exactly — by reading
one row past the page, say — sets this and the guess is not used.
None means “not known”, not “no more”.
Implementations§
Source§impl<R> Listing<R>
impl<R> Listing<R>
Sourcepub fn new(rows: impl IntoIterator<Item = R>) -> Self
pub fn new(rows: impl IntoIterator<Item = R>) -> Self
A page of rows, with nothing else known about the collection.