Skip to main content

ArrayOfMaps

Struct ArrayOfMaps 

Source
pub struct ArrayOfMaps<T, V = MapData> { /* private fields */ }
Expand description

An array of eBPF maps.

An ArrayOfMaps stores references to other eBPF maps.

§Minimum kernel version

The minimum kernel version required to use this feature is 4.12.

Implementations§

Source§

impl<T: Borrow<MapData>, V> ArrayOfMaps<T, V>

Source

pub fn len(&self) -> u32

Returns the number of elements in the array.

This corresponds to the value of bpf_map_def::max_entries on the eBPF side.

Source

pub fn is_empty(&self) -> bool

Returns true if the array is empty.

Source§

impl<T: Borrow<MapData>, V: FromMapData> ArrayOfMaps<T, V>

Source

pub fn get(&self, index: &u32, flags: u64) -> Result<V, MapError>

Returns the inner map stored at the given index.

The inner map type V is determined by the type parameter on the ArrayOfMaps itself.

§File descriptor cost

Each call opens a new file descriptor to the inner map. The caller owns the returned map and its FD is closed on drop. Avoid calling this in a tight loop without dropping previous results.

§Errors

Returns MapError::OutOfBounds if index is out of bounds, MapError::SyscallError if bpf_map_lookup_elem fails.

Source§

impl<T: BorrowMut<MapData>, V: InnerMap> ArrayOfMaps<T, V>

Source

pub fn set(&mut self, index: u32, value: &V, flags: u64) -> Result<(), MapError>

Sets the value of the element at the given index.

§Errors

Returns MapError::OutOfBounds if index is out of bounds, MapError::SyscallError if bpf_map_update_elem fails.

Source§

impl<V> ArrayOfMaps<MapData, V>

Source

pub fn pin<P: AsRef<Path>>(self, path: P) -> Result<(), PinError>

Pins the map to a BPF filesystem.

When a map is pinned it will remain loaded until the corresponding file is deleted. All parent directories in the given path must already exist.

Trait Implementations§

Source§

impl<T: Debug, V> Debug for ArrayOfMaps<T, V>

Source§

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

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

impl<'a, V: InnerMap> TryFrom<&'a Map> for ArrayOfMaps<&'a MapData, V>

Source§

type Error = MapError

The type returned in the event of a conversion error.
Source§

fn try_from(map: &'a Map) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'a, V: InnerMap> TryFrom<&'a mut Map> for ArrayOfMaps<&'a mut MapData, V>

Source§

type Error = MapError

The type returned in the event of a conversion error.
Source§

fn try_from(map: &'a mut Map) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<V: InnerMap> TryFrom<Map> for ArrayOfMaps<MapData, V>

Source§

type Error = MapError

The type returned in the event of a conversion error.
Source§

fn try_from(map: Map) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl<T, V> Freeze for ArrayOfMaps<T, V>
where T: Freeze,

§

impl<T, V> RefUnwindSafe for ArrayOfMaps<T, V>

§

impl<T, V> Send for ArrayOfMaps<T, V>
where T: Send, V: Send,

§

impl<T, V> Sync for ArrayOfMaps<T, V>
where T: Sync, V: Sync,

§

impl<T, V> Unpin for ArrayOfMaps<T, V>
where T: Unpin, V: Unpin,

§

impl<T, V> UnsafeUnpin for ArrayOfMaps<T, V>
where T: UnsafeUnpin,

§

impl<T, V> UnwindSafe for ArrayOfMaps<T, V>
where T: UnwindSafe, V: UnwindSafe,

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.