libbpf_rs

Struct PerfBufferBuilder

Source
pub struct PerfBufferBuilder<'a, 'b, M>
where M: MapCore,
{ /* private fields */ }
Expand description

Builds PerfBuffer instances.

Implementations§

Source§

impl<'a, M> PerfBufferBuilder<'a, '_, M>
where M: MapCore,

Source

pub fn new(map: &'a M) -> Self

Create a new PerfBufferBuilder using the provided MapCore object.

Source§

impl<'a, 'b, M> PerfBufferBuilder<'a, 'b, M>
where M: MapCore,

Source

pub fn sample_cb<F>(self, cb: F) -> PerfBufferBuilder<'a, 'b, M>
where F: FnMut(i32, &[u8]) + 'b,

Callback to run when a sample is received.

This callback provides a raw byte slice. You may find libraries such as plain helpful.

Callback arguments are: (cpu, data).

Source

pub fn lost_cb<F>(self, cb: F) -> PerfBufferBuilder<'a, 'b, M>
where F: FnMut(i32, u64) + 'b,

Callback to run when a sample is received.

Callback arguments are: (cpu, lost_count).

Source

pub fn pages(self, pages: usize) -> PerfBufferBuilder<'a, 'b, M>

The number of pages to size the ring buffer.

Source

pub fn build(self) -> Result<PerfBuffer<'b>>

Build the PerfBuffer object as configured.

Trait Implementations§

Source§

impl<M> Debug for PerfBufferBuilder<'_, '_, M>
where M: MapCore,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, 'b, M> Freeze for PerfBufferBuilder<'a, 'b, M>

§

impl<'a, 'b, M> !RefUnwindSafe for PerfBufferBuilder<'a, 'b, M>

§

impl<'a, 'b, M> !Send for PerfBufferBuilder<'a, 'b, M>

§

impl<'a, 'b, M> !Sync for PerfBufferBuilder<'a, 'b, M>

§

impl<'a, 'b, M> Unpin for PerfBufferBuilder<'a, 'b, M>

§

impl<'a, 'b, M> !UnwindSafe for PerfBufferBuilder<'a, 'b, M>

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.