Struct object::write::elf::AttributesWriter

source ·
pub struct AttributesWriter { /* private fields */ }
Expand description

A helper for writing an attributes section.

Attributes have a variable length encoding, so it is awkward to write them in a single pass. Instead, we build the entire attributes section data in memory, using placeholders for unknown lengths that are filled in later.

Implementations§

source§

impl AttributesWriter

source

pub fn new(endian: Endianness) -> Self

Create a new AttributesWriter for the given endianness.

source

pub fn start_subsection(&mut self, vendor: &[u8])

Start a new subsection with the given vendor name.

source

pub fn end_subsection(&mut self)

End the subsection.

The subsection length is automatically calculated and written.

source

pub fn start_subsubsection(&mut self, tag: u8)

Start a new sub-subsection with the given tag.

source

pub fn write_subsubsection_index(&mut self, index: u32)

Write a section or symbol index to the sub-subsection.

The user must also call this function to write the terminating 0 index.

source

pub fn write_subsubsection_indices(&mut self, indices: &[u8])

Write raw index data to the sub-subsection.

The terminating 0 index is automatically written.

source

pub fn write_attribute_tag(&mut self, tag: u64)

Write an attribute tag to the sub-subsection.

source

pub fn write_attribute_integer(&mut self, value: u64)

Write an attribute integer value to the sub-subsection.

source

pub fn write_attribute_string(&mut self, value: &[u8])

Write an attribute string value to the sub-subsection.

The value must not include the null terminator.

source

pub fn write_subsubsection_attributes(&mut self, attributes: &[u8])

Write raw attribute data to the sub-subsection.

source

pub fn end_subsubsection(&mut self)

End the sub-subsection.

The sub-subsection length is automatically calculated and written.

source

pub fn data(self) -> Vec<u8>

Return the completed section data.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.