Skip to main content

Dyn

Trait Dyn 

Source
pub trait Dyn: Debug + Pod {
    type Word: Into<u64>;
    type Sword: Into<i64>;
    type Endian: Endian;

    // Required methods
    fn d_tag(&self, endian: Self::Endian) -> Self::Sword;
    fn d_val(&self, endian: Self::Endian) -> Self::Word;

    // Provided methods
    fn tag(&self, endian: Self::Endian) -> i64 { ... }
    fn val(&self, endian: Self::Endian) -> u64 { ... }
    fn tag32(&self, endian: Self::Endian) -> Option<i32> { ... }
    fn val32(&self, endian: Self::Endian) -> Option<u32> { ... }
    fn is_string(&self, endian: Self::Endian) -> bool { ... }
    fn string<'data, R: ReadRef<'data>>(
        &self,
        endian: Self::Endian,
        strings: StringTable<'data, R>,
    ) -> Result<&'data [u8]> { ... }
    fn is_address(&self, endian: Self::Endian) -> bool { ... }
}
Expand description

A trait for generic access to elf::Dyn32 and elf::Dyn64.

Required Associated Types§

Required Methods§

Source

fn d_tag(&self, endian: Self::Endian) -> Self::Sword

Source

fn d_val(&self, endian: Self::Endian) -> Self::Word

Provided Methods§

Source

fn tag(&self, endian: Self::Endian) -> i64

Get the tag as an i64.

This will sign-extend for 32-bit ELF.

Source

fn val(&self, endian: Self::Endian) -> u64

Get the value as a u64.

This will zero-extend for 32-bit ELF.

Source

fn tag32(&self, endian: Self::Endian) -> Option<i32>

Try to convert the tag to an i32.

Source

fn val32(&self, endian: Self::Endian) -> Option<u32>

Try to convert the value to a u32.

Source

fn is_string(&self, endian: Self::Endian) -> bool

Return true if the value is an offset in the dynamic string table.

Source

fn string<'data, R: ReadRef<'data>>( &self, endian: Self::Endian, strings: StringTable<'data, R>, ) -> Result<&'data [u8]>

Use the value to get a string in a string table.

Does not check for an appropriate tag.

Source

fn is_address(&self, endian: Self::Endian) -> bool

Return true if the value is an address.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<Endian: Endian> Dyn for Dyn32<Endian>

Source§

type Word = u32

Source§

type Sword = i32

Source§

type Endian = Endian

Source§

impl<Endian: Endian> Dyn for Dyn64<Endian>

Source§

type Word = u64

Source§

type Sword = i64

Source§

type Endian = Endian