pub struct ReadFuture<'ring, 'buf> { /* private fields */ }Expand description
Future for file read operations.
This future polls the completion queue until the read operation completes, then returns the number of bytes read and buffer ownership. The future ensures proper cleanup of waker registrations and handles both successful completions and error conditions.
§Type Parameters
'ring- Lifetime of the io_uring Ring instance'buf- Lifetime of the buffer used for the read operation
§Returns
Returns (usize, Pin<&'buf mut [u8]>) on success where:
usizeis the number of bytes readPin<&'buf mut [u8]>is the buffer with read data
§Examples
ⓘ
let mut ring = Ring::new(32)?;
let mut buffer = PinnedBuffer::with_capacity(1024);
let file = File::open("example.txt")?;
// Buffer lifetime must outlive the operation
let read_future = ring.read(file.as_raw_fd(), buffer.as_mut_slice())?;
let (bytes_read, _buffer) = read_future.await?;
println!("Read {} bytes", bytes_read);Trait Implementations§
Source§impl<'ring, 'buf> Drop for ReadFuture<'ring, 'buf>
impl<'ring, 'buf> Drop for ReadFuture<'ring, 'buf>
Auto Trait Implementations§
impl<'ring, 'buf> Freeze for ReadFuture<'ring, 'buf>
impl<'ring, 'buf> !RefUnwindSafe for ReadFuture<'ring, 'buf>
impl<'ring, 'buf> Send for ReadFuture<'ring, 'buf>
impl<'ring, 'buf> Sync for ReadFuture<'ring, 'buf>
impl<'ring, 'buf> Unpin for ReadFuture<'ring, 'buf>
impl<'ring, 'buf> !UnwindSafe for ReadFuture<'ring, 'buf>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<F> IntoFuture for Fwhere
F: Future,
impl<F> IntoFuture for Fwhere
F: Future,
Source§type IntoFuture = F
type IntoFuture = F
Which kind of future are we turning this into?
Source§fn into_future(self) -> <F as IntoFuture>::IntoFuture
fn into_future(self) -> <F as IntoFuture>::IntoFuture
Creates a future from a value. Read more