Struct contiguous_mem::ByteRange
source · pub struct ByteRange(pub usize, pub usize);Expand description
Represents a range of bytes in
AllocationTracker and
ContiguousMemoryStorage.
Tuple Fields§
§0: usizeInclusive lower bound of this byte range.
1: usizeExclusive upper bound of this byte range.
Implementations§
source§impl ByteRange
impl ByteRange
sourcepub fn new(from: usize, to: usize) -> Self
pub fn new(from: usize, to: usize) -> Self
Constructs a new byte range, ensuring that from and to are ordered
correctly.
sourcepub fn new_unchecked(from: usize, to: usize) -> Self
pub fn new_unchecked(from: usize, to: usize) -> Self
Constructs a new byte range without checking from and to ordering.
sourcepub fn aligned(&self, alignment: usize) -> Self
pub fn aligned(&self, alignment: usize) -> Self
Aligns this byte range to the provided alignment.
sourcepub fn cap_size(&self, size: usize) -> Option<Self>
pub fn cap_size(&self, size: usize) -> Option<Self>
Caps the size of this byte range to the provided size and returns it.
If the size of this byte range is lesser than the required size, None
is returned instead.
sourcepub fn offset(&self, offset: usize) -> Self
pub fn offset(&self, offset: usize) -> Self
Offsets this byte range by a provided unsigned offset.
sourcepub fn offset_signed(&self, offset: isize) -> Self
pub fn offset_signed(&self, offset: isize) -> Self
Offsets this byte range by a provided signed offset.
sourcepub fn contains(&self, other: Self) -> bool
pub fn contains(&self, other: Self) -> bool
Returns true if this byte range contains another byte range other.
sourcepub fn difference_unchecked(&self, other: Self) -> (Self, Self)
pub fn difference_unchecked(&self, other: Self) -> (Self, Self)
Returns two byte ranges that remain when another other range is
removed from this one.
It is possible for either or both of the returned byte ranges to have a
length of 0 if other is aligned with either the upper or lower bound
of this range, or if it is equal to this range.
sourcepub fn merge_unchecked(&self, other: Self) -> Self
pub fn merge_unchecked(&self, other: Self) -> Self
Merges this byte range with other and returns a byte range that
contains both.
sourcepub fn merge_in_unchecked(&mut self, other: Self)
pub fn merge_in_unchecked(&mut self, other: Self)
Merges another other byte range into this one, resulting in a byte
range that contains both.