pub struct Array<V: Copy + Default + Sized> { /* private fields */ }

Implementations

Creates a new BPF array with entries elements. The kernel zero-initializes all elements on creation.

Arguments
  • entries - The number of elements in the array.
Example
use bpf_api::collections::Array;

let array = Array::<u32>::create(10).expect("Failed to create array");

Retrieves the value for a given element.

Arguments
  • index - The element index to retrieve.
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);

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);

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

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.