pub struct WriteFuture<'ring, 'buf> { /* private fields */ }Expand description
Future for file write operations.
This future polls the completion queue until the write operation completes, then returns the number of bytes written and buffer ownership. Like all I/O futures in this crate, it ensures proper resource cleanup and handles error conditions gracefully.
§Type Parameters
'ring- Lifetime of the io_uring Ring instance'buf- Lifetime of the buffer containing data to write
§Returns
Returns (usize, Pin<&'buf mut [u8]>) on success where:
usizeis the number of bytes writtenPin<&'buf mut [u8]>is the buffer that was written from
§Examples
ⓘ
let mut ring = Ring::new(32)?;
let mut buffer = PinnedBuffer::from_slice(b"Hello, world!");
let file = OpenOptions::new()
.write(true)
.create(true)
.open("output.txt")?;
let write_future = ring.write(file.as_raw_fd(), buffer.as_mut_slice())?;
let (bytes_written, _buffer) = write_future.await?;
println!("Wrote {} bytes", bytes_written);Trait Implementations§
Source§impl<'ring, 'buf> Drop for WriteFuture<'ring, 'buf>
impl<'ring, 'buf> Drop for WriteFuture<'ring, 'buf>
Auto Trait Implementations§
impl<'ring, 'buf> Freeze for WriteFuture<'ring, 'buf>
impl<'ring, 'buf> !RefUnwindSafe for WriteFuture<'ring, 'buf>
impl<'ring, 'buf> Send for WriteFuture<'ring, 'buf>
impl<'ring, 'buf> Sync for WriteFuture<'ring, 'buf>
impl<'ring, 'buf> Unpin for WriteFuture<'ring, 'buf>
impl<'ring, 'buf> !UnwindSafe for WriteFuture<'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