pub struct Array<V: Copy + Default> { /* private fields */ }
Expand description
An array that exposes an idiomatic Rust interface to an underlying BPF array.
Implementations§
Source§impl<V: Copy + Default> Array<V>
impl<V: Copy + Default> Array<V>
Sourcepub fn with_capacity(entries: u32) -> Result<Self, Error>
pub fn with_capacity(entries: u32) -> Result<Self, Error>
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>::with_capacity(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>::with_capacity(10).expect("Failed to create array");
array.get_identifier();
Auto Trait Implementations§
impl<V> !Freeze for Array<V>
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§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more