Skip to main content

PerfEventArrayBuffer

Struct PerfEventArrayBuffer 

Source
pub struct PerfEventArrayBuffer<T> { /* private fields */ }
Expand description

A ring buffer that can receive events from eBPF programs.

PerfEventArrayBuffer is a ring buffer that can receive events from eBPF programs that use bpf_perf_event_output(). It’s returned by PerfEventArray::open.

See the PerfEventArray documentation for an overview of how to use perf buffers.

Implementations§

Source§

impl<T: BorrowMut<MapData>> PerfEventArrayBuffer<T>

Source

pub fn readable(&self) -> bool

Returns true if the buffer contains events that haven’t been read.

Source

pub fn try_fold<B, C, F>(&mut self, init: C, f: F) -> ControlFlow<B, C>
where F: FnMut(C, PerfEvent<'_>) -> ControlFlow<B, C>,

Processes events available in the buffer with f.

For each available event, f receives the accumulator and event:

If the buffer is fully drained, returns ControlFlow::Continue containing the final accumulator.

The slices in PerfEvent::Sample are borrowed directly from the perf ring buffer; the borrow is bounded by the closure invocation. The kernel-visible data_tail is advanced once at the end of the call, amortizing the SeqCst store across the drain.

Source

pub fn fold<C, F>(&mut self, init: C, f: F) -> C
where F: FnMut(C, PerfEvent<'_>) -> C,

Processes events available in the buffer with f.

For each available event, f receives the accumulator and event, and returns the next accumulator. Unlike PerfEventArrayBuffer::try_fold, this function cannot short-circuit: it always processes events until the buffer is fully drained, then returns the final accumulator.

Source

pub fn for_each<F>(&mut self, f: F)
where F: FnMut(PerfEvent<'_>),

Processes events available in the buffer with f.

Trait Implementations§

Source§

impl<T: BorrowMut<MapData>> AsFd for PerfEventArrayBuffer<T>

Source§

fn as_fd(&self) -> BorrowedFd<'_>

Borrows the file descriptor. Read more
Source§

impl<T: BorrowMut<MapData>> AsRawFd for PerfEventArrayBuffer<T>

Source§

fn as_raw_fd(&self) -> RawFd

Extracts the raw file descriptor. Read more

Auto Trait Implementations§

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.