pub struct HashMap<T: Deref<Target = Map>, K, V> { /* private fields */ }
Expand description

A hash map that can be shared between eBPF programs and user space.

Minimum kernel version

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

Examples

use aya::maps::HashMap;
use std::convert::TryFrom;

let mut redirect_ports = HashMap::try_from(bpf.map_mut("REDIRECT_PORTS")?)?;

// redirect port 80 to 8080
redirect_ports.insert(80, 8080, 0);
// redirect port 443 to 8443
redirect_ports.insert(443, 8443, 0);

Implementations

Returns a copy of the value associated with the key.

An iterator visiting all key-value pairs in arbitrary order. The iterator item type is Result<(K, V), MapError>.

An iterator visiting all keys in arbitrary order. The iterator element type is Result<K, MapError>.

Inserts a key-value pair into the map.

Removes a key from the map.

Trait Implementations

Get a generic map handle

Get the value for the provided key

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.