Struct libbpf_rs::OpenObject

source ·
pub struct OpenObject { /* private fields */ }
Expand description

Represents an opened (but not yet loaded) BPF object file.

Use this object to access OpenMaps and OpenPrograms.

Implementations§

source§

impl OpenObject

source

pub unsafe fn from_ptr(ptr: NonNull<bpf_object>) -> Result<Self>

Takes ownership from pointer.

§Safety

Operations on the returned object are undefined if ptr is any one of: - null - points to an unopened bpf_object - points to a loaded bpf_object

It is not safe to manipulate ptr after this operation.

source

pub fn take_ptr(self) -> NonNull<bpf_object>

Takes underlying libbpf_sys::bpf_object pointer.

source

pub fn name(&self) -> Result<&str>

Retrieve the object’s name.

source

pub fn map<T: AsRef<str>>(&self, name: T) -> Option<&OpenMap>

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

source

pub fn map_mut<T: AsRef<str>>(&mut self, name: T) -> Option<&mut OpenMap>

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

source

pub fn maps_iter(&self) -> impl Iterator<Item = &OpenMap>

Get an iterator over references to all OpenMaps. Note that this will include automatically generated .data, .rodata, .bss, and .kconfig maps.

source

pub fn maps_iter_mut(&mut self) -> impl Iterator<Item = &mut OpenMap>

Get an iterator over mutable references to all OpenMaps. Note that this will include automatically generated .data, .rodata, .bss, and .kconfig maps.

source

pub fn prog<T: AsRef<str>>(&self, name: T) -> Option<&OpenProgram>

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

source

pub fn prog_mut<T: AsRef<str>>(&mut self, name: T) -> Option<&mut OpenProgram>

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

source

pub fn progs_iter(&self) -> impl Iterator<Item = &OpenProgram>

Get an iterator over references to all OpenPrograms.

source

pub fn progs_iter_mut(&mut self) -> impl Iterator<Item = &mut OpenProgram>

Get an iterator over mutable references to all OpenPrograms.

source

pub fn load(self) -> Result<Object>

Load the maps and programs contained in this BPF object into the system.

Trait Implementations§

source§

impl Debug for OpenObject

source§

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

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

impl Drop for OpenObject

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

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.