Struct StringSectionAccessor

Source
pub struct StringSectionAccessor<'a> { /* private fields */ }
Expand description

A section data accessor intended to string tables

For example:

use std::fs::File;
use std::io;
use std::io::{BufReader, Error};
use elfio::{Elfio, StringSectionAccessor}; // Uncomment in the real code

fn main() -> io::Result<()> {
    let elf_file = File::open("tests/files/hello_64")?;
    let mut file_reader = BufReader::new(elf_file);

    let mut elf = elfio::Elfio::new();

    elf.load(&mut file_reader)?;

    let section = elf.get_section_by_name(".strtab");

    match section {
        Some(s) => {
            let strtab = StringSectionAccessor::new(&elf, s);
            println!("{}", strtab.get_string(1));
        }
        None => return Err(Error::new(io::ErrorKind::Other, "section not found")),
    }

    Ok(())
}

Implementations§

Source§

impl<'a> StringSectionAccessor<'a>

Source

pub fn new( elfio: &'a Elfio, section: &'a dyn ElfSectionTrait, ) -> StringSectionAccessor<'a>

Creates a new instance of the string table accessor

Source

pub fn get_string(&self, index: ElfWord) -> String

Returns a string from string table by its index

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.