libbpf_rs

Struct MapImpl

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

Represents a libbpf-created map.

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

Implementations§

Source§

impl<'obj> MapImpl<'obj>

Source

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

Create a Map from a libbpf_sys::bpf_map.

Source

pub fn is_pinned(&self) -> bool

Returns whether map is pinned or not flag

Source

pub fn get_pin_path(&self) -> Option<&OsStr>

Returns the pin_path if the map is pinned, otherwise, None is returned

Source§

impl<'obj> MapImpl<'obj, Mut>

Source

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

Create a MapMut from a libbpf_sys::bpf_map.

Source

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

Pin this map to bpffs.

Source

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

Unpin this map from bpffs.

Source

pub fn attach_struct_ops(&mut self) -> Result<Link>

Attach a struct ops map

Trait Implementations§

Source§

impl<T> AsFd for MapImpl<'_, T>

Source§

fn as_fd(&self) -> BorrowedFd<'_>

Borrows the file descriptor. Read more
Source§

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

Source§

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

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

impl<T> MapCore for MapImpl<'_, T>
where T: Debug,

Source§

fn name(&self) -> &OsStr

Retrieve the map’s name.
Source§

fn map_type(&self) -> MapType

Retrieve type of the map.
Source§

fn key_size(&self) -> u32

Retrieve the size of the map’s keys.
Source§

fn value_size(&self) -> u32

Retrieve the size of the map’s values.
Source§

fn info(&self) -> Result<MapInfo>

Fetch extra map information
Source§

fn keys(&self) -> MapKeyIter<'_>

Returns an iterator over keys in this map Read more
Source§

fn lookup(&self, key: &[u8], flags: MapFlags) -> Result<Option<Vec<u8>>>

Returns map value as Vec of u8. Read more
Source§

fn lookup_bloom_filter(&self, value: &[u8]) -> Result<bool>

Returns if the given value is likely present in bloom_filter as bool. Read more
Source§

fn lookup_percpu( &self, key: &[u8], flags: MapFlags, ) -> Result<Option<Vec<Vec<u8>>>>

Returns one value per cpu as Vec of Vec of u8 for per per-cpu maps. Read more
Source§

fn delete(&self, key: &[u8]) -> Result<()>

Deletes an element from the map. Read more
Source§

fn delete_batch( &self, keys: &[u8], count: u32, elem_flags: MapFlags, flags: MapFlags, ) -> Result<()>

Deletes many elements in batch mode from the map. Read more
Source§

fn lookup_and_delete(&self, key: &[u8]) -> Result<Option<Vec<u8>>>

Same as Self::lookup() except this also deletes the key from the map. Read more
Source§

fn update(&self, key: &[u8], value: &[u8], flags: MapFlags) -> Result<()>

Update an element. Read more
Source§

fn update_batch( &self, keys: &[u8], values: &[u8], count: u32, elem_flags: MapFlags, flags: MapFlags, ) -> Result<()>

Updates many elements in batch mode in the map Read more
Source§

fn update_percpu( &self, key: &[u8], values: &[Vec<u8>], flags: MapFlags, ) -> Result<()>

Update an element in an per-cpu map with one value per cpu. Read more
Source§

impl<T> TryFrom<&MapImpl<'_, T>> for MapHandle
where T: Debug,

Source§

type Error = Error

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

fn try_from(other: &MapImpl<'_, T>) -> Result<Self>

Performs the conversion.

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

impl<'obj, T> UnwindSafe for MapImpl<'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.