Skip to content

Commit eba5dfa

Browse files
d-e-s-odanielocfb
authored andcommitted
Make RingBufferBuilder work with MapHandle
In our current vision, a MapHandle is the "more general" version of a Map. We don't need the RingBufferBuilder to work only with Map objects specifically. Rather, by accepting a MapHandle we open the door to using both Map and MapHandle objects. Signed-off-by: Daniel Müller <[email protected]>
1 parent 8a04b54 commit eba5dfa

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

libbpf-rs/src/ringbuf.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use std::time::Duration;
1515
use crate::libbpf_sys;
1616
use crate::util;
1717
use crate::Error;
18-
use crate::Map;
18+
use crate::MapHandle;
1919
use crate::MapType;
2020
use crate::Result;
2121

@@ -45,9 +45,9 @@ impl Debug for RingBufferCallback<'_> {
4545

4646
/// Builds [`RingBuffer`] instances.
4747
///
48-
/// `ringbuf`s are a special kind of [`Map`], used to transfer data between
49-
/// [`Program`][crate::Program]s and userspace. As of Linux 5.8, the `ringbuf`
50-
/// map is now preferred over the `perf buffer`.
48+
/// `ringbuf`s are a special kind of [`Map`][crate::Map], used to transfer data
49+
/// between [`Program`][crate::Program]s and userspace. As of Linux 5.8, the
50+
/// `ringbuf` map is now preferred over the `perf buffer`.
5151
#[derive(Debug, Default)]
5252
pub struct RingBufferBuilder<'a> {
5353
fd_callbacks: Vec<(BorrowedFd<'a>, RingBufferCallback<'a>)>,
@@ -69,7 +69,7 @@ impl<'a> RingBufferBuilder<'a> {
6969
///
7070
/// The callback provides a raw byte slice. You may find libraries such as
7171
/// [`plain`](https://crates.io/crates/plain) helpful.
72-
pub fn add<NewF>(&mut self, map: &'a Map, callback: NewF) -> Result<&mut Self>
72+
pub fn add<NewF>(&mut self, map: &'a MapHandle, callback: NewF) -> Result<&mut Self>
7373
where
7474
NewF: FnMut(&[u8]) -> i32 + 'a,
7575
{
@@ -141,9 +141,9 @@ impl<'a> RingBufferBuilder<'a> {
141141

142142
/// The canonical interface for managing a collection of `ringbuf` maps.
143143
///
144-
/// `ringbuf`s are a special kind of [`Map`], used to transfer data between
145-
/// [`Program`][crate::Program]s and userspace. As of Linux 5.8, the `ringbuf`
146-
/// map is now preferred over the `perf buffer`.
144+
/// `ringbuf`s are a special kind of [`Map`][crate::Map], used to transfer data
145+
/// between [`Program`][crate::Program]s and userspace. As of Linux 5.8, the
146+
/// `ringbuf` map is now preferred over the `perf buffer`.
147147
#[derive(Debug)]
148148
pub struct RingBuffer<'a> {
149149
ptr: NonNull<libbpf_sys::ring_buffer>,

0 commit comments

Comments
 (0)