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>
impl Btf<'static>
Sourcepub fn from_path<P: AsRef<Path>>(path: P) -> Result<Self>
pub fn from_path<P: AsRef<Path>>(path: P) -> Result<Self>
Load the btf information from specified path.
Sourcepub fn from_vmlinux() -> Result<Self>
pub fn from_vmlinux() -> Result<Self>
Load the vmlinux btf information from few well-known locations.
Sourcepub fn from_prog_id(id: u32) -> Result<Self>
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>
impl<'btf> Btf<'btf>
Sourcepub fn from_bpf_object(obj: &'btf bpf_object) -> Result<Option<Self>>
pub fn from_bpf_object(obj: &'btf bpf_object) -> Result<Option<Self>>
Create a new Btf
instance from the given libbpf_sys::bpf_object
.
Sourcepub fn from_raw(
name: &'btf str,
object_file: &'btf [u8],
) -> Result<Option<Self>>
pub fn from_raw( name: &'btf str, object_file: &'btf [u8], ) -> Result<Option<Self>>
From raw bytes coming from an object file.
Sourcepub fn ptr_size(&self) -> Result<NonZeroUsize>
pub fn ptr_size(&self) -> Result<NonZeroUsize>
The btf pointer size.
Sourcepub fn type_by_name<'s, K>(&'s self, name: &str) -> Option<K>
pub fn type_by_name<'s, K>(&'s self, name: &str) -> Option<K>
Sourcepub fn type_by_id<'s, K>(&'s self, type_id: TypeId) -> Option<K>
pub fn type_by_id<'s, K>(&'s self, type_id: TypeId) -> Option<K>
Find a type by it’s TypeId.
Sourcepub fn type_by_kind<'s, K>(&'s self) -> impl Iterator<Item = K> + 's
pub fn type_by_kind<'s, K>(&'s self) -> impl Iterator<Item = K> + 's
Find all types of a specific type kind.
Trait Implementations§
Source§impl AsRawLibbpf for Btf<'_>
impl AsRawLibbpf for Btf<'_>
Source§fn as_libbpf_object(&self) -> NonNull<Self::LibbpfType>
fn as_libbpf_object(&self) -> NonNull<Self::LibbpfType>
Retrieve the underlying libbpf_sys::btf
object.
Source§type LibbpfType = btf
type LibbpfType = btf
The underlying
libbpf
type.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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more