pub trait SocketPacketReader: Send {
type Message: SocketRecvMessageMut<Payload: ReceiveBuffer>;
// Required methods
fn read(
&mut self,
cancellation: &Cancellation,
) -> impl Future<Output = OperationResult<Option<Self::Message>>> + Send;
fn read_into(
&mut self,
buffer: &mut [u8],
cancellation: &Cancellation,
) -> impl Future<Output = OperationResult<SocketRecvResult>> + Send;
fn read_vectored(
&mut self,
buffers: &mut [IoSliceMut<'_>],
cancellation: &Cancellation,
) -> impl Future<Output = OperationResult<SocketRecvResult>> + Send;
fn read_vectored_with_flags(
&mut self,
buffers: &mut [IoSliceMut<'_>],
flags: SocketRecvFlags,
cancellation: &Cancellation,
) -> impl Future<Output = OperationResult<SocketRecvResult>> + Send;
fn read_owned_vectored<Buffers: IoBufSequenceMut>(
&mut self,
buffers: Buffers,
flags: SocketRecvFlags,
cancellation: &Cancellation,
) -> impl Future<Output = (OperationResult<SocketRecvResult>, Buffers)> + Send;
fn close(&mut self) -> impl Future<Output = Result<()>> + Send;
// Provided methods
fn read_into_with_flags(
&mut self,
buffer: &mut [u8],
flags: SocketRecvFlags,
cancellation: &Cancellation,
) -> impl Future<Output = OperationResult<SocketRecvResult>> + Send { ... }
fn read_owned<B: IoBufMut>(
&mut self,
buffer: B,
cancellation: &Cancellation,
) -> impl Future<Output = (OperationResult<SocketRecvResult>, B)> + Send { ... }
}Expand description
Sequential packet reception through a fixed execution service. Each read consumes at most one packet and preserves its sender and truncation metadata. Empty packets are messages, not EOF.
If an owned-operation future is abandoned while backend access continues, subsequent operations may report WouldBlock until it retires. Await close to establish retirement; separate handles provide independent lanes.
Required Associated Types§
Sourcetype Message: SocketRecvMessageMut<Payload: ReceiveBuffer>
type Message: SocketRecvMessageMut<Payload: ReceiveBuffer>
The owned message returned by read, whose payload is pooled receive storage.
Required Methods§
Sourcefn read(
&mut self,
cancellation: &Cancellation,
) -> impl Future<Output = OperationResult<Option<Self::Message>>> + Send
fn read( &mut self, cancellation: &Cancellation, ) -> impl Future<Output = OperationResult<Option<Self::Message>>> + Send
Receive independently owned storage. None means the reader has been closed. Retained messages remain valid after subsequent reads, pool replacement, and close. Pool exhaustion waits with cancellation.
Sourcefn read_into(
&mut self,
buffer: &mut [u8],
cancellation: &Cancellation,
) -> impl Future<Output = OperationResult<SocketRecvResult>> + Send
fn read_into( &mut self, buffer: &mut [u8], cancellation: &Cancellation, ) -> impl Future<Output = OperationResult<SocketRecvResult>> + Send
Receive one packet into reused borrowed storage. A short buffer truncates that packet; no subsequent read recovers its discarded suffix. An empty packet returns zero bytes successfully.
Sourcefn read_vectored(
&mut self,
buffers: &mut [IoSliceMut<'_>],
cancellation: &Cancellation,
) -> impl Future<Output = OperationResult<SocketRecvResult>> + Send
fn read_vectored( &mut self, buffers: &mut [IoSliceMut<'_>], cancellation: &Cancellation, ) -> impl Future<Output = OperationResult<SocketRecvResult>> + Send
Receive one packet across borrowed vectors in order. The vectors are not advanced; the returned count and truncation flags describe the whole packet attempt.
Sourcefn read_vectored_with_flags(
&mut self,
buffers: &mut [IoSliceMut<'_>],
flags: SocketRecvFlags,
cancellation: &Cancellation,
) -> impl Future<Output = OperationResult<SocketRecvResult>> + Send
fn read_vectored_with_flags( &mut self, buffers: &mut [IoSliceMut<'_>], flags: SocketRecvFlags, cancellation: &Cancellation, ) -> impl Future<Output = OperationResult<SocketRecvResult>> + Send
Perform one borrowed vectored transfer with explicit flags. Vectors are never advanced implicitly; a short result leaves their ranges unchanged.
Sourcefn read_owned_vectored<Buffers: IoBufSequenceMut>(
&mut self,
buffers: Buffers,
flags: SocketRecvFlags,
cancellation: &Cancellation,
) -> impl Future<Output = (OperationResult<SocketRecvResult>, Buffers)> + Send
fn read_owned_vectored<Buffers: IoBufSequenceMut>( &mut self, buffers: Buffers, flags: SocketRecvFlags, cancellation: &Cancellation, ) -> impl Future<Output = (OperationResult<SocketRecvResult>, Buffers)> + Send
Transfer one message using an owned buffer sequence with explicit flags. Return the original sequence and its unchanged ranges on success, error, and cancellation. Kernel or worker access retains the full owner and stable I/O vectors through retirement, including after future abandonment.
Provided Methods§
Sourcefn read_into_with_flags(
&mut self,
buffer: &mut [u8],
flags: SocketRecvFlags,
cancellation: &Cancellation,
) -> impl Future<Output = OperationResult<SocketRecvResult>> + Send
fn read_into_with_flags( &mut self, buffer: &mut [u8], flags: SocketRecvFlags, cancellation: &Cancellation, ) -> impl Future<Output = OperationResult<SocketRecvResult>> + Send
Perform one borrowed transfer with explicit portable flags. Payload access ends before each poll returns; successful progress is returned in that poll.
Sourcefn read_owned<B: IoBufMut>(
&mut self,
buffer: B,
cancellation: &Cancellation,
) -> impl Future<Output = (OperationResult<SocketRecvResult>, B)> + Send
fn read_owned<B: IoBufMut>( &mut self, buffer: B, cancellation: &Cancellation, ) -> impl Future<Output = (OperationResult<SocketRecvResult>, B)> + Send
Perform one transfer while retaining a stable owner and return that original owner with every collected result. Backends may retain it independently until access retires after waiter abandonment.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".