libbpf_rs

Struct OpenMapImpl

Source
pub struct OpenMapImpl<'obj, T = ()> { /* private fields */ }
Expand description

Represents a parsed but not yet loaded BPF map.

This object exposes operations that need to happen before the map is created.

Some methods require working with raw bytes. You may find libraries such as plain helpful.

Implementations§

Source§

impl<'obj> OpenMapImpl<'obj>

Source

pub fn new(object: &'obj bpf_map) -> Self

Create a new OpenMap from a ptr to a libbpf_sys::bpf_map.

Source

pub fn name(&self) -> &OsStr

Retrieve the OpenMap’s name.

Source

pub fn map_type(&self) -> MapType

Retrieve type of the map.

Source

pub fn initial_value(&self) -> Option<&[u8]>

Retrieve the initial value of the map.

Source§

impl<'obj> OpenMapImpl<'obj, Mut>

Source

pub fn new_mut(object: &'obj mut bpf_map) -> Self

Create a new OpenMapMut from a ptr to a libbpf_sys::bpf_map.

Source

pub fn initial_value_mut(&mut self) -> Option<&mut [u8]>

Retrieve the initial value of the map.

Source

pub fn set_map_ifindex(&mut self, idx: u32)

Bind map to a particular network device.

Used for offloading maps to hardware.

Source

pub fn set_initial_value(&mut self, data: &[u8]) -> Result<()>

Set the initial value of the map.

Source

pub fn set_type(&mut self, ty: MapType) -> Result<()>

Set the type of the map.

Source

pub fn set_key_size(&mut self, size: u32) -> Result<()>

Set the key size of the map in bytes.

Source

pub fn set_value_size(&mut self, size: u32) -> Result<()>

Set the value size of the map in bytes.

Source

pub fn set_max_entries(&mut self, count: u32) -> Result<()>

Set the maximum number of entries this map can have.

Source

pub fn set_map_flags(&mut self, flags: u32) -> Result<()>

Set flags on this map.

Source

pub fn set_numa_node(&mut self, numa_node: u32) -> Result<()>

Source

pub fn set_inner_map_fd(&mut self, inner_map_fd: BorrowedFd<'_>) -> Result<()>

Source

pub fn set_map_extra(&mut self, map_extra: u64) -> Result<()>

Source

pub fn set_autocreate(&mut self, autocreate: bool) -> Result<()>

Set whether or not libbpf should automatically create this map during load phase.

Source

pub fn set_pin_path<P: AsRef<Path>>(&mut self, path: P) -> Result<()>

Set where the map should be pinned.

Note this does not actually create the pin.

Source

pub fn reuse_fd(&mut self, fd: BorrowedFd<'_>) -> Result<()>

Reuse an fd for a BPF map

Source

pub fn reuse_pinned_map<P: AsRef<Path>>(&mut self, path: P) -> Result<()>

Reuse an already-pinned map for self.

Trait Implementations§

Source§

impl<T> AsRawLibbpf for OpenMapImpl<'_, T>

Source§

fn as_libbpf_object(&self) -> NonNull<Self::LibbpfType>

Retrieve the underlying libbpf_sys::bpf_map.

Source§

type LibbpfType = bpf_map

The underlying libbpf type.
Source§

impl<'obj, T: Debug> Debug for OpenMapImpl<'obj, T>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'obj, T> Freeze for OpenMapImpl<'obj, T>

§

impl<'obj, T> RefUnwindSafe for OpenMapImpl<'obj, T>
where T: RefUnwindSafe,

§

impl<'obj, T = ()> !Send for OpenMapImpl<'obj, T>

§

impl<'obj, T = ()> !Sync for OpenMapImpl<'obj, T>

§

impl<'obj, T> Unpin for OpenMapImpl<'obj, T>

§

impl<'obj, T> UnwindSafe for OpenMapImpl<'obj, T>
where T: RefUnwindSafe,

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>,

Source§

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>,

Source§

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.