Struct libbpf_rs::ObjectBuilder
source · pub struct ObjectBuilder { /* private fields */ }
Expand description
Builder for creating an OpenObject
. Typically the entry point into libbpf-rs.
Implementations§
source§impl ObjectBuilder
impl ObjectBuilder
sourcepub fn name<T: AsRef<str>>(&mut self, name: T) -> Result<&mut Self>
pub fn name<T: AsRef<str>>(&mut self, name: T) -> Result<&mut Self>
Override the generated name that would have been inferred from the constructor.
sourcepub fn pin_root_path<T: AsRef<Path>>(&mut self, path: T) -> Result<&mut Self>
pub fn pin_root_path<T: AsRef<Path>>(&mut self, path: T) -> Result<&mut Self>
Set the pin_root_path for maps that are pinned by name.
By default, this is NULL which bpf translates to /sys/fs/bpf
sourcepub fn relaxed_maps(&mut self, relaxed_maps: bool) -> &mut Self
pub fn relaxed_maps(&mut self, relaxed_maps: bool) -> &mut Self
Option to parse map definitions non-strictly, allowing extra attributes/data
sourcepub fn debug(&mut self, dbg: bool) -> &mut Self
pub fn debug(&mut self, dbg: bool) -> &mut Self
Option to print debug output to stderr.
Note: This function uses set_print
internally and will overwrite any callbacks
currently in use.
sourcepub fn opts(&self) -> &bpf_object_open_opts
pub fn opts(&self) -> &bpf_object_open_opts
Get the raw libbpf_sys::bpf_object_open_opts.
The internal pointers are tied to the lifetime of the ObjectBuilder, so be wary when copying the struct or otherwise handing the lifetime over to C.
sourcepub fn open_file<P: AsRef<Path>>(&mut self, path: P) -> Result<OpenObject>
pub fn open_file<P: AsRef<Path>>(&mut self, path: P) -> Result<OpenObject>
Open an object using the provided path on the file system.
sourcepub fn open_memory(&mut self, mem: &[u8]) -> Result<OpenObject>
pub fn open_memory(&mut self, mem: &[u8]) -> Result<OpenObject>
Open an object from memory.