Struct libbpf_rs::Map[][src]

pub struct Map { /* fields omitted */ }

Represents a created map.

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

Implementations

impl Map[src]

pub fn name(&self) -> &str[src]

pub fn fd(&self) -> i32[src]

Returns a file descriptor to the underlying map.

pub fn map_type(&self) -> MapType[src]

pub fn key_size(&self) -> u32[src]

Key size in bytes

pub fn value_size(&self) -> u32[src]

Value size in bytes

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

Pin this map to bpffs.

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

Unpin from bpffs

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

Returns map value as Vec of u8.

key must have exactly Map::key_size() elements.

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

Deletes an element from the map.

key must have exactly Map::key_size() elements.

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

Same as Map::lookup() except this also deletes the key from the map.

Note that this operation is currently only implemented in the kernel for MapType::Queue and MapType::Stack.

key must have exactly Map::key_size() elements.

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

Update an element.

key must have exactly Map::key_size() elements. value must have exatly Map::value_size() elements.

pub fn keys(&self) -> MapKeyIter<'_>[src]

Returns an iterator over keys in this map

Note that if the map is not stable (stable meaning no updates or deletes) during iteration, iteration can skip keys, restart from the beginning, or duplicate keys. In other words, iteration becomes unpredictable.

Auto Trait Implementations

impl RefUnwindSafe for Map

impl !Send for Map

impl !Sync for Map

impl Unpin for Map

impl UnwindSafe for Map

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.