Struct redbpf::Map [−][src]
Expand description
A base BPF map data structure
It is a base data structure that contains a map definition and auxiliary
data. It just hods data but it does not provide any useful API to users.
See HashMap
,
LruHashMap
,
PerCpuHashMap
,
LruPerCpuHashMap
,
Array
, PerCpuArray
that wrap Map
to provide API of BPF maps to userspace programs.
Fields
name: String
kind: u32
Implementations
Create Map
from a file which represents pinned map
Example
use redbpf::{Array, Map};
let map = Map::from_pin_file("/sys/fs/bpf/persist_map").expect("error on creating map from file");
let array = Array::<u64>::new(&map).expect("error on creating array");
Pin map to BPF FS
Example
use redbpf::Module;
use redbpf::load::Loader;
let mut loaded = Loader::load_file("file.elf").expect("error loading probe");
loaded.map_mut("persist_map").expect("map not found").pin("/sys/fs/bpf/persist_map").expect("error on pinning");
Unpin map
Example
use redbpf::Module;
use redbpf::load::Loader;
let mut loaded = Loader::load_file("file.elf").expect("error loading probe");
let persist_map = loaded.map_mut("persist_map").expect("map not found");
persist_map.pin("/sys/fs/bpf/persist_map").expect("error on pinning");
// do some stuff...
persist_map.unpin().expect("error on unpinning");
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Map
impl UnwindSafe for Map
Blanket Implementations
Mutably borrows from an owned value. Read more
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more