pub struct AddressRange {
pub start: u64,
pub end: u64,
}Expand description
A half-open virtual-address range, [start, end).
Addresses are the unslid virtual addresses of the image the data describes,
so a runtime address must have its load bias removed before it is compared
against a range. See docs::symbolication.
An empty range is legal and means a function whose size the producer did not
know. Self::contains reports false for every address in that case, but
address lookup still resolves such a function, for addresses from its start
up to the next function.
use gsym::AddressRange;
let range = AddressRange::new(0x1000, 0x1020);
assert_eq!(range.size(), 0x20);
assert!(range.contains(0x1000));
assert!(!range.contains(0x1020));
// Endpoints are not checked on construction.
let reversed = AddressRange::new(0x20, 0x10);
assert!(!reversed.is_valid());
assert_eq!(reversed.size(), 0);
assert!(reversed.is_empty());Fields§
§start: u64Inclusive start address.
end: u64Exclusive end address.
Implementations§
Source§impl AddressRange
impl AddressRange
Sourcepub const fn new(start: u64, end: u64) -> Self
pub const fn new(start: u64, end: u64) -> Self
Creates a range without validating endpoint order.
Sourcepub const fn is_valid(self) -> bool
pub const fn is_valid(self) -> bool
Returns whether the start is less than or equal to the end.
Sourcepub const fn is_empty(self) -> bool
pub const fn is_empty(self) -> bool
Returns whether the range covers no addresses, including reversed ones.
This is defined as Self::size being zero, so it is also true for the
reversed endpoints Self::is_valid rejects: such a range covers
nothing, and Self::contains reports false for every address in it.
Sourcepub const fn contains(self, address: u64) -> bool
pub const fn contains(self, address: u64) -> bool
Returns whether address lies in this valid half-open range.
Sourcepub const fn contains_range(self, other: Self) -> bool
pub const fn contains_range(self, other: Self) -> bool
Returns whether this valid range fully contains other.
Trait Implementations§
Source§impl Clone for AddressRange
impl Clone for AddressRange
Source§fn clone(&self) -> AddressRange
fn clone(&self) -> AddressRange
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more