Struct libbpf_rs::Map[][src]

pub struct Map { /* fields omitted */ }
Expand description

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]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

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

pub fn from(t: T) -> T[src]

Performs the conversion.

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

pub fn into(self) -> U[src]

Performs the conversion.

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.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

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.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.