pub struct Page<M> {
pub items: Vec<M>,
pub total: Option<u64>,
pub next: Option<Cursor>,
pub totals: Vec<Total>,
pub groups: Vec<Group>,
}Expand description
One page of a list.
use zeyn::Page;
let page = Page::new(vec![1, 2, 3]).total(120);
assert_eq!(page.total, Some(120));Fields§
§items: Vec<M>§total: Option<u64>Total row count. Optional because counting can be expensive on large tables.
next: Option<Cursor>Where the next batch starts. None means there is nothing more.
totals: Vec<Total>Column totals over the whole filtered result, not only this page. Filled for the
aggregates the query asked for (DataQuery::aggregates).
groups: Vec<Group>Groups of rows, filled instead of items when the query asks for them
(DataQuery::group). total and next then count groups.
Implementations§
Source§impl<M> Page<M>
impl<M> Page<M>
pub fn new(items: Vec<M>) -> Self
Sourcepub fn with_total(
self,
field: impl Into<String>,
op: Aggregate,
value: Value,
) -> Self
pub fn with_total( self, field: impl Into<String>, op: Aggregate, value: Value, ) -> Self
Adds a column total. Data layers that page in SQL compute totals with one aggregate query.
pub fn total(self, total: u64) -> Self
pub fn next(self, cursor: Cursor) -> Self
Trait Implementations§
Source§impl<'de, M> Deserialize<'de> for Page<M>where
M: Deserialize<'de>,
impl<'de, M> Deserialize<'de> for Page<M>where
M: Deserialize<'de>,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl<M: PartialEq> StructuralPartialEq for Page<M>
Auto Trait Implementations§
impl<M> Freeze for Page<M>
impl<M> RefUnwindSafe for Page<M>where
Vec<M>: RefUnwindSafe,
impl<M> Send for Page<M>
impl<M> Sync for Page<M>
impl<M> Unpin for Page<M>
impl<M> UnsafeUnpin for Page<M>where
Vec<M>: UnsafeUnpin,
impl<M> UnwindSafe for Page<M>where
Vec<M>: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more