Skip to main content

Queue

Struct Queue 

Source
pub struct Queue<T, V: Pod> { /* private fields */ }
Expand description

A FIFO queue.

§Minimum kernel version

The minimum kernel version required to use this feature is 4.20.

§Examples

use aya::maps::Queue;

let mut queue = Queue::try_from(bpf.map_mut("ARRAY").unwrap())?;
queue.push(42, 0)?;
queue.push(43, 0)?;
assert_eq!(queue.pop(0)?, 42);

Implementations§

Source§

impl<T: Borrow<MapData>, V: Pod> Queue<T, V>

Source

pub fn capacity(&self) -> u32

Returns the number of elements the queue can hold.

This corresponds to the value of bpf_map_def::max_entries on the eBPF side.

Source§

impl<T: BorrowMut<MapData>, V: Pod> Queue<T, V>

Source

pub fn pop(&mut self, flags: u64) -> Result<V, MapError>

Removes the first element and returns it.

§Errors

Returns MapError::ElementNotFound if the queue is empty, MapError::SyscallError if bpf_map_lookup_and_delete_elem fails.

Source

pub fn push( &mut self, value: impl Borrow<V>, flags: u64, ) -> Result<(), MapError>

Appends an element at the end of the queue.

§Errors

MapError::SyscallError if bpf_map_update_elem fails.

Source§

impl<T: Borrow<MapData>, V: Pod> Queue<T, V>

Source

pub fn pin<P: AsRef<Path>>(self, path: P) -> Result<(), PinError>

Pins the map to a BPF filesystem.

When a map is pinned it will remain loaded until the corresponding file is deleted. All parent directories in the given path must already exist.

Source§

impl<V: Pod> Queue<MapData, V>

Source

pub fn create(max_entries: u32, flags: u32) -> Result<Self, MapError>

Creates a standalone map with the given max_entries capacity and flags.

Trait Implementations§

Source§

impl<'a, V: Pod> TryFrom<&'a Map> for Queue<&'a MapData, V>

Source§

type Error = MapError

The type returned in the event of a conversion error.
Source§

fn try_from(map: &'a Map) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'a, V: Pod> TryFrom<&'a mut Map> for Queue<&'a mut MapData, V>

Source§

type Error = MapError

The type returned in the event of a conversion error.
Source§

fn try_from(map: &'a mut Map) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<V: Pod> TryFrom<Map> for Queue<MapData, V>

Source§

type Error = MapError

The type returned in the event of a conversion error.
Source§

fn try_from(map: Map) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl<T, V> Freeze for Queue<T, V>
where T: Freeze,

§

impl<T, V> RefUnwindSafe for Queue<T, V>

§

impl<T, V> Send for Queue<T, V>
where T: Send, V: Send,

§

impl<T, V> Sync for Queue<T, V>
where T: Sync, V: Sync,

§

impl<T, V> Unpin for Queue<T, V>
where T: Unpin, V: Unpin,

§

impl<T, V> UnsafeUnpin for Queue<T, V>
where T: UnsafeUnpin,

§

impl<T, V> UnwindSafe for Queue<T, V>
where T: UnwindSafe, V: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> FromMapData for T
where T: FromMapData,

Source§

impl<T> InnerMap for T
where T: InnerMap,