Struct Btf

Source
pub struct Btf { /* private fields */ }
Expand description

Main representation of a parsed BTF object. Provides helpers to resolve types and their associated names.

Implementations§

Source§

impl Btf

Source

pub fn from_file<P: AsRef<Path>>(path: P) -> Result<Btf>

Parse a stand-alone BTF object file and construct a Rust representation for later use. Trying to open split BTF files using this function will fail. For split BTF files use Btf::from_split_file().

Source

pub fn from_split_file<P: AsRef<Path>>(path: P, base: &Btf) -> Result<Btf>

Parse a split BTF object file and construct a Rust representation for later use. A base Btf object must be provided.

Source

pub fn from_bytes(bytes: &[u8]) -> Result<Btf>

Performs the same actions as from_file(), but fed with a byte slice.

Source

pub fn from_split_bytes(bytes: &[u8], base: &Btf) -> Result<Btf>

Performs the same actions as from_split_file(), but fed with a byte slice.

Source

pub fn resolve_ids_by_name(&self, name: &str) -> Result<Vec<u32>>

Find a list of BTF ids using their name as a key.

Source

pub fn resolve_type_by_id(&self, id: u32) -> Result<Type>

Find a BTF type using its id as a key.

Source

pub fn resolve_types_by_name(&self, name: &str) -> Result<Vec<Type>>

Find a list of BTF types using their name as a key.

Source

pub fn resolve_name<T: BtfType + ?Sized>(&self, type: &T) -> Result<String>

Resolve a name referenced by a Type which is defined in the current BTF object.

Source

pub fn resolve_chained_type<T: BtfType + ?Sized>( &self, type: &T, ) -> Result<Type>

Types can have a reference to another one, e.g. Ptr -> Int. This helper resolve a Type referenced in an other one. It is the main helper to traverse the Type tree.

Source

pub fn type_iter<'a, T: BtfType + ?Sized>(&'a self, type: &'a T) -> TypeIter<'_>

This helper returns an iterator that allow to resolve a Type referenced in another one all the way down to the chain. The helper makes use of Btf::resolve_chained_type().

Auto Trait Implementations§

§

impl Freeze for Btf

§

impl RefUnwindSafe for Btf

§

impl Send for Btf

§

impl Sync for Btf

§

impl Unpin for Btf

§

impl UnwindSafe for Btf

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.