Trait object::read::ObjectSection
source · pub trait ObjectSection<'data>: Sealed {
type RelocationIterator: Iterator<Item = (u64, Relocation)>;
Show 17 methods
// Required methods
fn index(&self) -> SectionIndex;
fn address(&self) -> u64;
fn size(&self) -> u64;
fn align(&self) -> u64;
fn file_range(&self) -> Option<(u64, u64)>;
fn data(&self) -> Result<&'data [u8]>;
fn data_range(&self, address: u64, size: u64) -> Result<Option<&'data [u8]>>;
fn compressed_file_range(&self) -> Result<CompressedFileRange>;
fn compressed_data(&self) -> Result<CompressedData<'data>>;
fn name_bytes(&self) -> Result<&[u8]>;
fn name(&self) -> Result<&str>;
fn segment_name_bytes(&self) -> Result<Option<&[u8]>>;
fn segment_name(&self) -> Result<Option<&str>>;
fn kind(&self) -> SectionKind;
fn relocations(&self) -> Self::RelocationIterator;
fn flags(&self) -> SectionFlags;
// Provided method
fn uncompressed_data(&self) -> Result<Cow<'data, [u8]>> { ... }
}
Expand description
A section in an Object
.
This trait is part of the unified read API.
Required Associated Types§
sourcetype RelocationIterator: Iterator<Item = (u64, Relocation)>
type RelocationIterator: Iterator<Item = (u64, Relocation)>
An iterator for the relocations for a section.
The first field in the item tuple is the section offset that the relocation applies to.
Required Methods§
sourcefn index(&self) -> SectionIndex
fn index(&self) -> SectionIndex
Returns the section index.
sourcefn file_range(&self) -> Option<(u64, u64)>
fn file_range(&self) -> Option<(u64, u64)>
Returns offset and size of on-disk segment (if any).
sourcefn data(&self) -> Result<&'data [u8]>
fn data(&self) -> Result<&'data [u8]>
Returns the raw contents of the section.
The length of this data may be different from the size of the section in memory.
This does not do any decompression.
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 raw contents of the section data in the given range.
This does not do any decompression.
Returns Ok(None)
if the section does not contain the given range.
sourcefn compressed_file_range(&self) -> Result<CompressedFileRange>
fn compressed_file_range(&self) -> Result<CompressedFileRange>
Returns the potentially compressed file range of the section, along with information about the compression.
sourcefn compressed_data(&self) -> Result<CompressedData<'data>>
fn compressed_data(&self) -> Result<CompressedData<'data>>
Returns the potentially compressed contents of the section, along with information about the compression.
sourcefn name_bytes(&self) -> Result<&[u8]>
fn name_bytes(&self) -> Result<&[u8]>
Returns the name of the section.
sourcefn name(&self) -> Result<&str>
fn name(&self) -> Result<&str>
Returns the name of the section.
Returns an error if the name is not UTF-8.
sourcefn segment_name_bytes(&self) -> Result<Option<&[u8]>>
fn segment_name_bytes(&self) -> Result<Option<&[u8]>>
Returns the name of the segment for this section.
sourcefn segment_name(&self) -> Result<Option<&str>>
fn segment_name(&self) -> Result<Option<&str>>
Returns the name of the segment for this section.
Returns an error if the name is not UTF-8.
sourcefn kind(&self) -> SectionKind
fn kind(&self) -> SectionKind
Return the kind of this section.
sourcefn relocations(&self) -> Self::RelocationIterator
fn relocations(&self) -> Self::RelocationIterator
Get the relocations for this section.
sourcefn flags(&self) -> SectionFlags
fn flags(&self) -> SectionFlags
Section flags that are specific to each file format.
Provided Methods§
sourcefn uncompressed_data(&self) -> Result<Cow<'data, [u8]>>
fn uncompressed_data(&self) -> Result<Cow<'data, [u8]>>
Returns the uncompressed contents of the section.
The length of this data may be different from the size of the section in memory.
If no compression is detected, then returns the data unchanged.
Returns Err
if decompression fails.