Struct bpf_api::collections::Queue
source · [−]Implementations
sourceimpl<V: Copy + Default + Sized> Queue<V>
impl<V: Copy + Default + Sized> Queue<V>
sourcepub fn create(entries: u32) -> Result<Self, Error>
pub fn create(entries: u32) -> Result<Self, Error>
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");
sourcepub fn pop(&self) -> Result<V, Error>
pub fn pop(&self) -> Result<V, Error>
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(_)));
sourcepub fn front(&self) -> Result<V, Error>
pub fn front(&self) -> Result<V, Error>
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(_)));
sourcepub fn push(&self, val: V) -> Result<(), Error>
pub fn push(&self, val: V) -> Result<(), Error>
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(_)));
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::Queue;
let queue = Queue::<u32>::create(10).expect("Failed to create queue");
queue.get_identifier();
Auto Trait Implementations
impl<V> RefUnwindSafe for Queue<V>where
V: RefUnwindSafe,
impl<V> Send for Queue<V>where
V: Send,
impl<V> Sync for Queue<V>where
V: Sync,
impl<V> Unpin for Queue<V>where
V: Unpin,
impl<V> UnwindSafe for Queue<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