Struct libbpf_rs::btf::Btf

source ·
pub struct Btf<'source> { /* private fields */ }
Expand description

The btf information of a bpf object.

The lifetime bound protects against this object outliving its source. This can happen when it was derived from an Object, which owns the data this structs points too. When instead the Btf::from_path method is used, the lifetime will be 'static since it doesn’t borrow from anything.

Implementations§

source§

impl Btf<'static>

source

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

Load the btf information from specified path.

source

pub fn from_vmlinux() -> Result<Self>

Load the vmlinux btf information from few well-known locations.

source

pub fn from_prog_id(id: u32) -> Result<Self>

Load the btf information of an bpf object from a program id.

source§

impl<'btf> Btf<'btf>

source

pub fn from_bpf_object(obj: &'btf bpf_object) -> Result<Option<Self>>

Create a new Btf instance from the given libbpf_sys::bpf_object.

source

pub fn from_raw( name: &'btf str, object_file: &'btf [u8], ) -> Result<Option<Self>>

From raw bytes coming from an object file.

source

pub fn is_empty(&self) -> bool

Whether this btf instance has no types.

source

pub fn len(&self) -> usize

The number of BtfTypes in this object.

source

pub fn ptr_size(&self) -> Result<NonZeroUsize>

The btf pointer size.

source

pub fn type_by_name<'s, K>(&'s self, name: &str) -> Option<K>
where K: TryFrom<BtfType<'s>>,

Find a btf type by name

§Panics

If name has null bytes.

source

pub fn type_by_id<'s, K>(&'s self, type_id: TypeId) -> Option<K>
where K: TryFrom<BtfType<'s>>,

Find a type by it’s TypeId.

source

pub fn type_by_kind<'s, K>(&'s self) -> impl Iterator<Item = K> + 's
where K: TryFrom<BtfType<'s>>,

Find all types of a specific type kind.

Trait Implementations§

source§

impl AsRawLibbpf for Btf<'_>

source§

fn as_libbpf_object(&self) -> NonNull<Self::LibbpfType>

Retrieve the underlying libbpf_sys::btf object.

§

type LibbpfType = btf

The underlying libbpf type.
source§

impl<'source> Debug for Btf<'source>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Drop for Btf<'_>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'source> Freeze for Btf<'source>

§

impl<'source> RefUnwindSafe for Btf<'source>

§

impl<'source> !Send for Btf<'source>

§

impl<'source> !Sync for Btf<'source>

§

impl<'source> Unpin for Btf<'source>

§

impl<'source> UnwindSafe for Btf<'source>

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>,

§

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>,

§

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.