Struct bpf_api::collections::Array
source · [−]Implementations
sourceimpl<V: Copy + Default + Sized> Array<V>
impl<V: Copy + Default + Sized> Array<V>
sourcepub fn set(&self, index: u32, value: V) -> Result<(), Error>
pub fn set(&self, index: u32, value: V) -> Result<(), Error>
Sets the value at a given index.
Arguments
index
- The element index to retrieve.value
- The new value.
Example
use bpf_api::collections::Array;
let array = Array::<u32>::create(10).expect("Failed to create array");
assert_eq!(array.get(5).expect("Failed to get element 5"), 0);
assert!(matches!(array.set(5, 10), Ok(_)));
assert_eq!(array.get(5).expect("Failed to get element 5"), 10);
sourcepub fn get_identifier(&self) -> u32
pub fn get_identifier(&self) -> u32
Retrieve the BPF identifier for this map. This is the underlying file descriptor that’s used in eBPF programs.
Example
use bpf_api::collections::Array;
let array = Array::<u32>::create(10).expect("Failed to create array");
array.get_identifier();
Auto Trait Implementations
impl<V> RefUnwindSafe for Array<V>where
V: RefUnwindSafe,
impl<V> Send for Array<V>where
V: Send,
impl<V> Sync for Array<V>where
V: Sync,
impl<V> Unpin for Array<V>where
V: Unpin,
impl<V> UnwindSafe for Array<V>where
V: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more