pub struct Range {
pub offset: i64,
pub limit_to: Option<i64>,
}Expand description
A non-negative range representing rows to return.
A non-negative range for pagination. Uses Option<i64> for boundaries
where None means unbounded.
Fields§
§offset: i64Lower bound (0-based, inclusive). Always present.
limit_to: Option<i64>Upper bound (inclusive). None means unbounded (all remaining rows).
Implementations§
Source§impl Range
impl Range
Sourcepub fn new(offset: i64, limit_to: i64) -> Self
pub fn new(offset: i64, limit_to: i64) -> Self
Create a range from offset to upper bound (inclusive).
Sourcepub fn from_offset(offset: i64) -> Self
pub fn from_offset(offset: i64) -> Self
Create a range starting at the given offset with no upper bound.
Sourcepub fn limit_zero() -> Self
pub fn limit_zero() -> Self
The special limit-zero range (0 <= x <= -1).
Used to allow limit=0 queries per the API spec.
Sourcepub fn has_limit_zero(&self) -> bool
pub fn has_limit_zero(&self) -> bool
Check if this is the limit-zero range.
Sourcepub fn is_empty_range(&self) -> bool
pub fn is_empty_range(&self) -> bool
Check if this range is empty (lower > upper).
Sourcepub fn restrict(&self, max_rows: Option<i64>) -> Self
pub fn restrict(&self, max_rows: Option<i64>) -> Self
Restrict this range by applying a limit.
If max_rows is Some, ensures the range covers at most that many rows.
Sourcepub fn with_limit(&self, limit: i64) -> Self
pub fn with_limit(&self, limit: i64) -> Self
Apply a limit (number of rows).
Sourcepub fn with_offset(&self, offset: i64) -> Self
pub fn with_offset(&self, offset: i64) -> Self
Apply an offset.
Sourcepub fn convert_to_limit_zero(&self, fallback: &Range) -> Self
pub fn convert_to_limit_zero(&self, fallback: &Range) -> Self
Convert to limit-zero range if it has limit=0, else use fallback.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Range
impl<'de> Deserialize<'de> for Range
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>,
impl Copy for Range
impl Eq for Range
impl StructuralPartialEq for Range
Auto Trait Implementations§
impl Freeze for Range
impl RefUnwindSafe for Range
impl Send for Range
impl Sync for Range
impl Unpin for Range
impl UnsafeUnpin for Range
impl UnwindSafe for Range
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read more