Struct elfio::ModInfoSectionAccessor[][src]

pub struct ModInfoSectionAccessor<'a> { /* fields omitted */ }
Expand description

A section data accessor intended to modinfo tables. The accessor is useful for kernel modules data

For example:

use std::fs::File;
use std::io;
use std::io::{BufReader, Error};

use elfio::Elfio;

fn main() -> io::Result<()> {
    let elf_file = File::open("tests/files/i2c-gpio.ko")?;
    let mut reader = BufReader::new(elf_file);

    let mut elf = Elfio::new();

    elf.load(&mut reader)?;

    let section = match elf.get_section_by_name(&".modinfo") {
        Some(s) => s,
        None => return Err(Error::new(io::ErrorKind::Other, "section not found")),
    };

    let modinfo = elfio::ModInfoSectionAccessor::new(&elf, section);

    assert_eq!(modinfo.get_entries_num(), 10);
    assert_eq!(modinfo.get(&"description".to_string()).unwrap(), "Platform-independent bitbanging I2C driver");

    Ok(())
}

Implementations

Creates a new instance of the relocation table accessor

Returns the number of modinfo entries

Get iterator over all modinfo entries

Retrieve a value by its key

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.