Trait elf::parse::ParseAt

source ·
pub trait ParseAt: Sized {
    // Required methods
    fn parse_at<E: EndianParse>(
        endian: E,
        class: Class,
        offset: &mut usize,
        data: &[u8]
    ) -> Result<Self, ParseError>;
    fn size_for(class: Class) -> usize;

    // Provided method
    fn validate_entsize(
        class: Class,
        entsize: usize
    ) -> Result<usize, ParseError> { ... }
}
Expand description

Trait for safely parsing an ELF structure of a given class (32/64 bit) with an given endian-awareness at the given offset into the data buffer.

This is the trait that drives our elf parser, where the various ELF structures implement ParseAt in order to parse their Rust-native representation from a buffer, all using safe code.

Required Methods§

source

fn parse_at<E: EndianParse>( endian: E, class: Class, offset: &mut usize, data: &[u8] ) -> Result<Self, ParseError>

Parse this type by using the given endian-awareness and ELF class layout. This is generic on EndianParse in order to allow users to optimize for their expectations of data layout. See EndianParse for more details.

source

fn size_for(class: Class) -> usize

Returns the expected size of the type being parsed for the given ELF class

Provided Methods§

source

fn validate_entsize(class: Class, entsize: usize) -> Result<usize, ParseError>

Checks whether the given entsize matches what we need to parse this type

Returns a ParseError for bad/unexpected entsizes that don’t match what this type parses.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl ParseAt for u32

source§

fn parse_at<E: EndianParse>( endian: E, _class: Class, offset: &mut usize, data: &[u8] ) -> Result<Self, ParseError>

source§

fn size_for(_class: Class) -> usize

source§

impl ParseAt for u64

source§

fn parse_at<E: EndianParse>( endian: E, _class: Class, offset: &mut usize, data: &[u8] ) -> Result<Self, ParseError>

source§

fn size_for(_class: Class) -> usize

Implementors§