wireshift-uring 0.1.1

Native Linux io_uring backend for wireshift
Documentation
use std::alloc::Layout;

pub struct RegisteredBuffers {
    pub allocations: Vec<(*mut u8, Layout)>,
}

unsafe impl Send for RegisteredBuffers {}

impl std::fmt::Debug for RegisteredBuffers {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(
            f,
            "RegisteredBuffers(count={}, size={})",
            self.allocations.len(),
            self.allocations
                .first()
                .map_or(0, |(_, layout)| layout.size())
        )
    }
}

impl Drop for RegisteredBuffers {
    fn drop(&mut self) {
        for (ptr, layout) in self.allocations.drain(..) {
            // SAFETY: Each (ptr, layout) pair was returned by std::alloc::alloc
            // during buffer registration and has not been freed elsewhere.
            unsafe {
                std::alloc::dealloc(ptr, layout);
            }
        }
    }
}