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§
sourcefn parse_at<E: EndianParse>(
endian: E,
class: Class,
offset: &mut usize,
data: &[u8]
) -> Result<Self, ParseError>
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.
Provided Methods§
sourcefn validate_entsize(class: Class, entsize: usize) -> Result<usize, ParseError>
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.