Trait object::read::ObjectSegment
source · pub trait ObjectSegment<'data>: Sealed {
// Required methods
fn address(&self) -> u64;
fn size(&self) -> u64;
fn align(&self) -> u64;
fn file_range(&self) -> (u64, u64);
fn data(&self) -> Result<&'data [u8]>;
fn data_range(&self, address: u64, size: u64) -> Result<Option<&'data [u8]>>;
fn name_bytes(&self) -> Result<Option<&[u8]>>;
fn name(&self) -> Result<Option<&str>>;
fn flags(&self) -> SegmentFlags;
}
Expand description
A loadable segment in an Object
.
This trait is part of the unified read API.
Required Methods§
sourcefn file_range(&self) -> (u64, u64)
fn file_range(&self) -> (u64, u64)
Returns the offset and size of the segment in the file.
sourcefn data(&self) -> Result<&'data [u8]>
fn data(&self) -> Result<&'data [u8]>
Returns a reference to the file contents of the segment.
The length of this data may be different from the size of the segment in memory.
sourcefn data_range(&self, address: u64, size: u64) -> Result<Option<&'data [u8]>>
fn data_range(&self, address: u64, size: u64) -> Result<Option<&'data [u8]>>
Return the segment data in the given range.
Returns Ok(None)
if the segment does not contain the given range.
sourcefn name_bytes(&self) -> Result<Option<&[u8]>>
fn name_bytes(&self) -> Result<Option<&[u8]>>
Returns the name of the segment.
sourcefn name(&self) -> Result<Option<&str>>
fn name(&self) -> Result<Option<&str>>
Returns the name of the segment.
Returns an error if the name is not UTF-8.
sourcefn flags(&self) -> SegmentFlags
fn flags(&self) -> SegmentFlags
Return the flags of segment.