Crates.io | libbpf-async |
lib.rs | libbpf-async |
version | 0.2.0 |
source | src |
created_at | 2021-11-05 01:25:45.922902 |
updated_at | 2024-01-30 01:20:16.384568 |
description | library for writing BPF programs in Async Rust, complementary for libbpf-rs |
homepage | https://github.com/fujita/libbpf-async |
repository | https://github.com/fujita/libbpf-async |
max_upload_size | |
id | 477132 |
size | 7,704 |
A library for writing BPF programs in Async Rust, complementary for libbpf-rs, Rust wrapper for libbpf.
Currently, this provides Async-friendly APIs for BPF ring buffer.
To use in your project, add into your Cargo.toml
:
[dependencies]
libbpf-async = "0.1"
#[tokio::main]
async fn main() {
let mut builder = TracerSkelBuilder::default();
let mut skel = builder.open().unwrap().load().unwrap();
let mut rb = libbpf_async::RingBuffer::new(skel.obj.map_mut("ringbuf").unwrap());
loop {
let mut buf = [0; 128];
let n = rb.read(&mut buf).await.unwrap();
// do something useful with the buffer
}
}
A working example code can be found here.
This work is dual-licensed under BSD 2-clause license and GNU LGPL v2.1 license. You can choose between one of them if you use this work.