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_end(&self, position: usize) -> Self
pub fn cap_end(&self, position: usize) -> Self
Caps the end address of this byte range to the provided position.
Sourcepub fn cap_size(&self, size: usize) -> Self
pub fn cap_size(&self, size: usize) -> Self
Caps the size of this byte range to the provided size.
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.