Struct libbpf_rs::RingBufferBuilder
source · pub struct RingBufferBuilder<'a> { /* private fields */ }
Expand description
Builds RingBuffer
instances.
ringbuf
s are a special kind of Map
, used to transfer data between
Program
s and userspace. As of Linux 5.8, the ringbuf
map is now preferred over the perf buffer
.
Implementations§
source§impl<'a> RingBufferBuilder<'a>
impl<'a> RingBufferBuilder<'a>
sourcepub fn add<NewF>(&mut self, map: &Map, callback: NewF) -> Result<&mut Self>where
NewF: FnMut(&[u8]) -> i32 + 'a,
pub fn add<NewF>(&mut self, map: &Map, callback: NewF) -> Result<&mut Self>where NewF: FnMut(&[u8]) -> i32 + 'a,
Add a new ringbuf map
and associated callback
to this ring buffer
manager. The callback should take one argument, a slice of raw bytes,
and return an i32.
Non-zero return values in the callback will stop ring buffer consumption early.
The callback provides a raw byte slice. You may find libraries such as
plain
helpful.
sourcepub fn build(self) -> Result<RingBuffer<'a>>
pub fn build(self) -> Result<RingBuffer<'a>>
Build a new RingBuffer
. Must have added at least one ringbuf.
Trait Implementations§
source§impl<'a> Debug for RingBufferBuilder<'a>
impl<'a> Debug for RingBufferBuilder<'a>
source§impl<'a> Default for RingBufferBuilder<'a>
impl<'a> Default for RingBufferBuilder<'a>
source§fn default() -> RingBufferBuilder<'a>
fn default() -> RingBufferBuilder<'a>
Returns the “default value” for a type. Read more