feat: Add `set` for `Array<T>`

Signed-off-by: jinlong <jinlong@tencent.com>
reviewable/pr1005/r3
jinlong 9 months ago committed by Tamir Duberstein
parent 0ae6e08a3e
commit 488e5c55c3
No known key found for this signature in database

@ -1,8 +1,10 @@
use core::{cell::UnsafeCell, marker::PhantomData, mem, ptr::NonNull};
use aya_ebpf_cty::c_long;
use crate::{
bindings::{bpf_map_def, bpf_map_type::BPF_MAP_TYPE_ARRAY},
lookup,
insert, lookup,
maps::PinningType,
};
@ -65,4 +67,10 @@ impl<T> Array<T> {
unsafe fn lookup(&self, index: u32) -> Option<NonNull<T>> {
lookup(self.def.get(), &index)
}
/// Sets the value of the element at the given index.
#[inline(always)]
pub fn set(&self, index: u32, value: &T, flags: u64) -> Result<(), c_long> {
insert(self.def.get(), &index, value, flags)
}
}

Loading…
Cancel
Save