Struct libbpf_rs::Object[][src]

pub struct Object { /* fields omitted */ }
Expand description

Represents a loaded BPF object file.

An Object is logically in charge of all the contained Programs and Maps as well as the associated metadata and runtime state that underpins the userspace portions of BPF program execution. As a libbpf-rs user, you must keep the Object alive during the entire lifetime of your interaction with anything inside the Object.

Note that this is an explanation of the motivation – Rust’s lifetime system should already be enforcing this invariant.

Implementations

impl Object[src]

pub unsafe fn from_ptr(ptr: *mut bpf_object) -> Result<Self>[src]

Takes ownership from pointer.

Safety

If ptr is not already loaded then further operations on the returned object are undefined.

It is not safe to manipulate ptr after this operation.

pub fn map<T: AsRef<str>>(&self, name: T) -> Option<&Map>[src]

Get a reference to Map with the name name, if one exists.

pub fn map_mut<T: AsRef<str>>(&mut self, name: T) -> Option<&mut Map>[src]

Get a mutable reference to Map with the name name, if one exists.

pub fn maps_iter(&self) -> impl Iterator<Item = &Map>[src]

Get an iterator over references to all Maps. Note that this will include automatically generated .data, .rodata, .bss, and .kconfig maps. You may wish to filter this.

pub fn maps_iter_mut(&mut self) -> impl Iterator<Item = &mut Map>[src]

Get an iterator over mutable references to all Maps. Note that this will include automatically generated .data, .rodata, .bss, and .kconfig maps. You may wish to filter this.

pub fn prog<T: AsRef<str>>(&self, name: T) -> Option<&Program>[src]

Get a reference to Program with the name name, if one exists.

pub fn prog_mut<T: AsRef<str>>(&mut self, name: T) -> Option<&mut Program>[src]

Get a mutable reference to Program with the name name, if one exists.

pub fn progs_iter(&self) -> impl Iterator<Item = &Program>[src]

Get an iterator over references to all Programs.

pub fn progs_iter_mut(&mut self) -> impl Iterator<Item = &mut Program>[src]

Get an iterator over mutable references to all Programs.

Trait Implementations

impl Drop for Object[src]

fn drop(&mut self)[src]

Executes the destructor for this type. Read more

Auto Trait Implementations

impl RefUnwindSafe for Object

impl !Send for Object

impl !Sync for Object

impl Unpin for Object

impl UnwindSafe for Object

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.