pub struct Section {
pub header: SectionHeader,
pub entry_header: EntryHeader,
/* private fields */
}Expand description
Represents a section in a sub-image.
This struct encapsulates a section within the image, consisting of the following components:
header: The metadata and configuration for the section (represented bySectionHeader).entry_header: The header that defines the entry point and loading address of the section (represented byEntryHeader).data: AVec<u8>containing the raw data for the section, which can be processed or manipulated as needed.
§Default Values:
- The
headerandentry_headerare initialized with their default values. - The
datais an empty vector by default.
Fields§
§header: SectionHeaderThe metadata and configuration for the section.
entry_header: EntryHeaderThe header that defines the entry point and loading address of the section.
Implementations§
Source§impl Section
impl Section
Sourcepub fn new_with_size(capacity: usize) -> Section
pub fn new_with_size(capacity: usize) -> Section
Creates a new Section with a specified data capacity.
This static method allows you to create a new Section with a predefined data capacity.
The data field will be initialized as a vector of zeroed bytes with the given size.
§Parameters:
capacity: The size (in bytes) to which thedatavector should be initialized.
§Returns:
A new Section instance with the specified capacity for its data field.
§Example:
let section = Section::new_with_size(1024);Sourcepub fn build_aligned_length(&self) -> u32
pub fn build_aligned_length(&self) -> u32
Computes the aligned length of the section data, ensuring it is padded to a 0x20-byte boundary.
This function calculates the total length of the section (including the EntryHeader and the
section’s data) and ensures that the result is aligned to a 0x20-byte boundary.
§Returns:
u32: The aligned length of the section, including theEntryHeaderand section data.
Sourcepub fn build_aligned_size(&self) -> u32
pub fn build_aligned_size(&self) -> u32
Computes the aligned size of the section, including the SectionHeader, EntryHeader, and section data.
§Returns:
u32: The aligned size of the section, including headers and data.
Trait Implementations§
Source§impl FromStream for Section
impl FromStream for Section
Auto Trait Implementations§
impl Freeze for Section
impl RefUnwindSafe for Section
impl Send for Section
impl Sync for Section
impl Unpin for Section
impl UnwindSafe for Section
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more