pub fn with_ctrl_ring<T, F>(closure: F) -> TExpand description
Execute a closure with access to the thread-local control ring
This function provides access to the control ring for read-only operations.
The control ring must be initialized first via ublk_init_ctrl_task_ring()
or by creating a UblkCtrl instance.
§Arguments
closure- A closure that receives&IoUring<squeue::Entry128>and returnsT
§Returns
The result of executing the closure
§Panics
Panics if the control ring is not initialized
§Examples
use libublk::{with_ctrl_ring, ublk_init_ctrl_task_ring};
use io_uring::{IoUring, squeue};
use std::os::fd::AsRawFd;
// Initialize the control ring first
ublk_init_ctrl_task_ring(|ring_opt| {
if ring_opt.is_none() {
*ring_opt = Some(IoUring::<squeue::Entry128>::builder().build(32)?);
}
Ok(())
})?;
// Now access it read-only
let fd = with_ctrl_ring(|ring| ring.as_raw_fd());
println!("Control ring fd: {}", fd);