push-packet 0.1.0

Packet-inspection and routing library for Linux, built on eBPF XDP and AF_XDP with aya.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use aya::{
    Pod,
    maps::{Array, MapData},
};

use crate::Error;

pub(crate) trait ArrayExt<V> {
    fn clear(&mut self, index: u32, name: &str) -> Result<(), Error>;
}

impl<V: Default + Pod> ArrayExt<V> for Array<MapData, V> {
    fn clear(&mut self, index: u32, name: &str) -> Result<(), Error> {
        self.set(index, V::default(), 0)
            .map_err(|e| Error::map(name, e))?;
        Ok(())
    }
}