pub struct SlotRange { /* private fields */ }Expand description
An inclusive [start, end] slot range. Construct via SlotRange::new,
which rejects an inverted range, or SlotRange::new_unchecked where the
ordering is already guaranteed by the caller.
Implementations§
Source§impl SlotRange
impl SlotRange
Sourcepub fn new(start: u64, end: u64) -> Result<Self, InvertedSlotRange>
pub fn new(start: u64, end: u64) -> Result<Self, InvertedSlotRange>
An inclusive range, rejecting start > end.
Sourcepub const fn new_unchecked(start: u64, end: u64) -> Self
pub const fn new_unchecked(start: u64, end: u64) -> Self
A range whose ordering the caller already guarantees — e.g. one derived
from a start plus a non-zero count. Prefer SlotRange::new.
Sourcepub const fn from_count(start: u64, count: u64) -> Self
pub const fn from_count(start: u64, count: u64) -> Self
The range covering count slots from start. count of 0 yields a
single-slot range, matching how the callers’ slot counts behave.
pub const fn start(&self) -> u64
Sourcepub const fn is_empty(&self) -> bool
pub const fn is_empty(&self) -> bool
Never true — an inclusive range always covers at least one slot. Present
so len() doesn’t trip clippy::len_without_is_empty.
pub const fn contains(&self, slot: u64) -> bool
Sourcepub fn slots_before(&self, slot: u64) -> u64
pub fn slots_before(&self, slot: u64) -> u64
0 before the start, len() past the end.
Sourcepub const fn overlaps(&self, other: SlotRange) -> bool
pub const fn overlaps(&self, other: SlotRange) -> bool
Whether the two ranges share at least one slot.
Sourcepub const fn covers(&self, other: SlotRange) -> bool
pub const fn covers(&self, other: SlotRange) -> bool
Whether other lies wholly within this range.
Sourcepub fn intersection(self, other: SlotRange) -> Option<SlotRange>
pub fn intersection(self, other: SlotRange) -> Option<SlotRange>
The slots both ranges share.