bpf-api 0.3.1

Idomatic Rust bindings for eBPF programs, probes, and maps.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use bpf_api::collections::Array;

fn main() {
    const ARRAY_SIZE: u32 = 10;
    let array = Array::<u32>::with_capacity(ARRAY_SIZE).unwrap();

    for i in 0..ARRAY_SIZE {
        let val = i + 100;
        assert!(matches!(array.get(i), Ok(0)));
        assert!(array.set(i, val).is_ok());
        match array.get(i) {
            Ok(v) => assert_eq!(v, val),
            Err(e) => panic!("array.get() failed: {}", e),
        }
    }
}