pub struct RecvFuture<'ring, 'buf> { /* private fields */ }Expand description
Future for socket receive operations.
This future receives data from a socket connection and returns the number of bytes received along with buffer ownership when the operation completes. The buffer will contain the received data upon successful completion.
§Type Parameters
'ring- Lifetime of the io_uring Ring instance'buf- Lifetime of the buffer to receive data into
§Returns
Returns (usize, Pin<&'buf mut [u8]>) on success where:
usizeis the number of bytes receivedPin<&'buf mut [u8]>is the buffer containing the received data
§Examples
ⓘ
let mut ring = Ring::new(32)?;
let mut buffer = PinnedBuffer::with_capacity(1024);
let stream = TcpStream::connect("127.0.0.1:8080")?;
stream.set_nonblocking(true)?;
let recv_future = ring.recv(stream.as_raw_fd(), buffer.as_mut_slice())?;
let (bytes_received, _buffer) = recv_future.await?;
println!("Received {} bytes", bytes_received);Trait Implementations§
Source§impl<'ring, 'buf> Drop for RecvFuture<'ring, 'buf>
impl<'ring, 'buf> Drop for RecvFuture<'ring, 'buf>
Auto Trait Implementations§
impl<'ring, 'buf> Freeze for RecvFuture<'ring, 'buf>
impl<'ring, 'buf> !RefUnwindSafe for RecvFuture<'ring, 'buf>
impl<'ring, 'buf> Send for RecvFuture<'ring, 'buf>
impl<'ring, 'buf> Sync for RecvFuture<'ring, 'buf>
impl<'ring, 'buf> Unpin for RecvFuture<'ring, 'buf>
impl<'ring, 'buf> !UnwindSafe for RecvFuture<'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