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

Implementations

Creates a new BPF queue with entries elements. A queue works as a FIFO container: push() inserts an element to the back and pop() consumes an element from the front.

Arguments
  • entries - The maximum number of elements in the queue.
Example
use bpf_api::collections::Queue;

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

Retrieves and removes the next element in the queue, if it exists.

Example
use bpf_api::collections::Queue;

let queue = Queue::<u32>::create(10).expect("Failed to create queue");
assert!(matches!(queue.pop(), Err(_)));

Retrieves next element in the queue, if it exists. This does not remove the element.

Example
use bpf_api::collections::Queue;

let queue = Queue::<u32>::create(10).expect("Failed to create queue");
assert!(matches!(queue.front(), Err(_)));

Push a new element to the back of the queue.

Example
use bpf_api::collections::Queue;

let queue = Queue::<u32>::create(10).expect("Failed to create queue");
assert!(matches!(queue.push(100), Ok(_)));
assert!(matches!(queue.front(), Ok(100)));
assert!(matches!(queue.pop(), Ok(100)));
assert!(matches!(queue.pop(), Err(_)));

Retrieve the BPF identifier for this map. This is the underlying file descriptor that’s used in eBPF programs.

Example
use bpf_api::collections::Queue;

let queue = Queue::<u32>::create(10).expect("Failed to create queue");
queue.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.