Skip to main content

Btf

Struct Btf 

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

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

Implementations§

Source§

impl Btf

Source

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

Parse a stand-alone BTF section from a file and construct a Rust representation for later use. By default Backend::Cache is used.

Trying to open split BTF files using this function will fail. For split BTF files use Btf::from_split_file.

Source

pub fn from_file_with_backend<P: AsRef<Path>>( path: P, backend: Backend, ) -> Result<Self>

Same as Btf::from_file but forcing a given Backend to be used. This allows selecting the desired behavior and balance, but can fail if a given Backend isn’t supported by the underlying system.

Source

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

Parse a split BTF section from a file and construct a Rust representation for later use. A base Btf containing the base section must be provided.

Source

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

Perform the same actions as Btf::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 Btf::from_split_file, but fed with a byte slice.

Source

pub fn base(&self) -> &BtfSection

Returns a reference the base BTF section. For non-split Btf the base BTF section holds the full BTF representation. Base BTF sections are standalone representations (no reference to external BTF sections).

Source

pub fn split(&self) -> Option<&BtfSection>

Returns a reference to the split BTF section, if any. A split BTF section is not a standalone representation (it uses references to a base BTF section).

Source

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

Find a list of BTF ids with a given name.

Using an empty name ("") resolves anonymous ids.

Source

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

Find a BTF type with a given id.

Source

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

Find a list of BTF types with a given name.

Using an empty name ("") resolves anonymous types.

Source

pub fn resolve_name(&self, type: &dyn BtfType) -> Result<String>

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

Source

pub fn type_iter(&self) -> TypeIter<'_>

Return an iterator over all types 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 chained_type_iter<T: BtfType + ?Sized>( &self, type: &T, ) -> ChainedTypeIter<'_>

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 !RefUnwindSafe for Btf

§

impl !UnwindSafe for Btf

§

impl Freeze for Btf

§

impl Send for Btf

§

impl Sync for Btf

§

impl Unpin for Btf

§

impl UnsafeUnpin 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.