libbpf_rs

Struct UserRingBuffer

Source
pub struct UserRingBuffer { /* private fields */ }
Expand description

Represents a user ring buffer. This is a special kind of map that is used to transfer data between user space and kernel space.

Implementations§

Source§

impl UserRingBuffer

Source

pub fn new(map: &dyn MapCore) -> Result<Self>

Create a new user ring buffer from a map.

§Errors
  • If the map is not a user ring buffer.
  • If the underlying libbpf function fails.
Source

pub fn reserve(&self, size: usize) -> Result<UserRingBufferSample<'_>>

Reserve a sample in the user ring buffer.

Returns a UserRingBufferSample that contains a mutable reference to sample that can be written to. The sample must be submitted via UserRingBuffer::submit before it is dropped.

§Parameters
  • size - The size of the sample in bytes.

This function is not thread-safe. It is necessary to synchronize amongst multiple producers when invoking this function.

Source

pub fn submit(&self, sample: UserRingBufferSample<'_>) -> Result<()>

Submit a sample to the user ring buffer.

This function takes ownership of the sample and submits it to the ring buffer. After submission, the consumer will be able to read the sample from the ring buffer.

This function is thread-safe. It is not necessary to synchronize amongst multiple producers when invoking this function.

Trait Implementations§

Source§

impl AsRawLibbpf for UserRingBuffer

Source§

fn as_libbpf_object(&self) -> NonNull<Self::LibbpfType>

Retrieve the underlying libbpf_sys::user_ring_buffer.

Source§

type LibbpfType = user_ring_buffer

The underlying libbpf type.
Source§

impl Debug for UserRingBuffer

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Drop for UserRingBuffer

Source§

fn drop(&mut self)

Executes the destructor for this type. 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.