Skip to main content

Paging

Struct Paging 

Source
pub struct Paging {
    pub window: Window,
    pub paged: bool,
}
Expand description

Where a reader is in a set that arrived in parts.

A Window wearing the paged reading of itself. Distinct from a carousel’s window at the top level on purpose, because the intent differs and a call site should say which one it means, while the arithmetic below is shared so the two cannot drift apart.

§The two idioms, and which one a renderer may draw

Load-more and numbered pages are both this type. Which is honest is paged: a set whose page size is known can be drawn as “Page 3 of 8”, and one without can only be drawn as “150 of 400” and a way forward. Saying it here rather than letting each renderer guess is the point — three renderers inferring it from the numbers is how they come to disagree.

§What it does not carry

No addresses. makeover-layout cannot name an action, and the way to ask for the next part is the host’s: quasi_router pairs this with the addresses the same way Row pairs its parts with Row::activate. That split is the reason this type is reusable by a carousel, which has nothing to ask.

Fields§

§window: Window

The window onto the set.

§paged: bool

Whether the parts are a fixed size, and so whether pages are countable.

false for load-more, where the window simply grew and “page 2” would name nothing.

Implementations§

Source§

impl Paging

Source

pub const fn pages(from: usize, per: usize) -> Self

A page of per, starting at from.

Source

pub const fn more(shown: usize) -> Self

The first shown, with more behind them.

The load-more shape: the window starts at the beginning and grows, so there is no page to number.

Source

pub const fn of(self, of: usize) -> Self

How many there are altogether.

Left unsaid by a host that cannot count, and left unsaid for good: a total arriving later widens whatever prints it. See “First paint is final paint” in the crate header.

Source

pub const fn page(self) -> Option<usize>

Which page this is, counting from one, when pages are countable.

One-based because it is read aloud. Window::index is the zero-based form for anyone indexing with it.

Source

pub const fn pages_total(self) -> Option<usize>

How many pages there are, when that is countable.

Source

pub const fn shown(self) -> usize

How many are on screen.

Source

pub const fn total(self) -> Option<usize>

How many there are, when the host counted.

Source

pub const fn remaining(self) -> Option<usize>

How many are not shown yet, when the host counted.

The figure a load-more control puts in its label. None is the honest and common case: a set that cannot say how many more there are still has a way to ask for them.

Source

pub const fn has_more(self) -> bool

Whether there is anything further on.

Source

pub const fn has_previous(self) -> bool

Whether there is anything back the other way.

Trait Implementations§

Source§

impl Clone for Paging

Source§

fn clone(&self) -> Paging

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Paging

Source§

impl Debug for Paging

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Paging

Source§

fn default() -> Paging

Returns the “default value” for a type. Read more
Source§

impl Eq for Paging

Source§

impl PartialEq for Paging

Source§

fn eq(&self, other: &Paging) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Paging

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.