pub struct SectionId(/* private fields */);Expand description
The identity of a section within its Object: its position in
Object::sections.
Ids are dense, starting at zero in the order sections were added, so they index straight into the section list. An id is only meaningful for the object that issued it.
§Examples
use object_lang::{Architecture, Object, Section, SectionKind};
let mut obj = Object::relocatable(Architecture::X86_64);
let text = obj.add_section(Section::new(".text", SectionKind::Text));
let data = obj.add_section(Section::new(".data", SectionKind::Data));
assert_eq!((text.index(), data.index()), (0, 1));Implementations§
Source§impl SectionId
impl SectionId
Sourcepub const fn new(index: u32) -> Self
pub const fn new(index: u32) -> Self
The id of the section at position index in Object::sections.
An id is only an index: one that names no section of the object it is used with
is caught by Object::validate (or refused by Object::section), never
trusted.
§Examples
use object_lang::{Architecture, Object, Section, SectionId, SectionKind};
let mut obj = Object::relocatable(Architecture::X86_64);
let text = obj.add_section(Section::new(".text", SectionKind::Text));
assert_eq!(SectionId::new(0), text);
assert!(obj.section(SectionId::new(1)).is_none());Sourcepub const fn index(self) -> usize
pub const fn index(self) -> usize
The position of the section in Object::sections.
§Examples
use object_lang::{Architecture, Object, Section, SectionKind};
let mut obj = Object::relocatable(Architecture::Aarch64);
let id = obj.add_section(Section::new(".text", SectionKind::Text));
assert_eq!(obj.sections()[id.index()].name(), ".text");Trait Implementations§
impl Copy for SectionId
impl Eq for SectionId
Source§impl Ord for SectionId
impl Ord for SectionId
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for SectionId
impl PartialOrd for SectionId
impl StructuralPartialEq for SectionId
Auto Trait Implementations§
impl Freeze for SectionId
impl RefUnwindSafe for SectionId
impl Send for SectionId
impl Sync for SectionId
impl Unpin for SectionId
impl UnsafeUnpin for SectionId
impl UnwindSafe for SectionId
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
Mutably borrows from an owned value. Read more