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 OpenMap
s and OpenProgram
s.
Implementations§
source§impl OpenObject
impl OpenObject
sourcepub unsafe fn from_ptr(ptr: NonNull<bpf_object>) -> Result<Self>
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.
sourcepub fn take_ptr(self) -> NonNull<bpf_object>
pub fn take_ptr(self) -> NonNull<bpf_object>
Takes underlying libbpf_sys::bpf_object
pointer.
sourcepub fn map<T: AsRef<str>>(&self, name: T) -> Option<&OpenMap>
pub fn map<T: AsRef<str>>(&self, name: T) -> Option<&OpenMap>
Get a reference to OpenMap
with the name name
, if one exists.
sourcepub fn map_mut<T: AsRef<str>>(&mut self, name: T) -> Option<&mut OpenMap>
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.
sourcepub fn maps_iter(&self) -> impl Iterator<Item = &OpenMap>
pub fn maps_iter(&self) -> impl Iterator<Item = &OpenMap>
Get an iterator over references to all OpenMap
s.
Note that this will include automatically generated .data, .rodata, .bss, and
.kconfig maps.
sourcepub fn maps_iter_mut(&mut self) -> impl Iterator<Item = &mut OpenMap>
pub fn maps_iter_mut(&mut self) -> impl Iterator<Item = &mut OpenMap>
Get an iterator over mutable references to all OpenMap
s.
Note that this will include automatically generated .data, .rodata, .bss, and
.kconfig maps.
sourcepub fn prog<T: AsRef<str>>(&self, name: T) -> Option<&OpenProgram>
pub fn prog<T: AsRef<str>>(&self, name: T) -> Option<&OpenProgram>
Get a reference to OpenProgram
with the name name
, if one exists.
sourcepub fn prog_mut<T: AsRef<str>>(&mut self, name: T) -> Option<&mut OpenProgram>
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.
sourcepub fn progs_iter(&self) -> impl Iterator<Item = &OpenProgram>
pub fn progs_iter(&self) -> impl Iterator<Item = &OpenProgram>
Get an iterator over references to all OpenProgram
s.
sourcepub fn progs_iter_mut(&mut self) -> impl Iterator<Item = &mut OpenProgram>
pub fn progs_iter_mut(&mut self) -> impl Iterator<Item = &mut OpenProgram>
Get an iterator over mutable references to all OpenProgram
s.