pub struct PageLimits {
pub limit: Option<usize>,
pub budget: usize,
}Expand description
How many items to collect, and how hard to work for them.
Fields§
§limit: Option<usize>Stop once this many items are held. None means everything.
budget: usizeMaximum number of HTTP requests, counting the first.
Separate from limit, and not a substitute for it: limit is what the
user asked for, this is the guard against a mistyped query walking a
large instance. Exhausting it marks the result truncated rather than
failing, so a partial answer is still labelled honestly.
Implementations§
Source§impl PageLimits
impl PageLimits
pub const DEFAULT_BUDGET: usize = 50
pub fn new(limit: Option<usize>) -> Self
Sourcepub fn from_cli_limit(limit: usize) -> Self
pub fn from_cli_limit(limit: usize) -> Self
Build limits from a CLI --limit, where 0 means everything.
The commands advertise --limit 0 for “all”. Passing it straight
through as Some(0) made items.len() >= 0 true on the first page, so
the result was truncated to nothing and the warning cheerfully advised
using the flag that had just emptied it.
pub fn with_budget(self, budget: usize) -> Self
Trait Implementations§
Source§impl Clone for PageLimits
impl Clone for PageLimits
impl Copy for PageLimits
Auto Trait Implementations§
impl Freeze for PageLimits
impl RefUnwindSafe for PageLimits
impl Send for PageLimits
impl Sync for PageLimits
impl Unpin for PageLimits
impl UnsafeUnpin for PageLimits
impl UnwindSafe for PageLimits
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