Skip to main content

SocketPacketReader

Trait SocketPacketReader 

Source
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§

Required Methods§

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

fn close(&mut self) -> impl Future<Output = Result<()>> + Send

Stop reading and await registration retirement without cancellation. Stop using the reader when close begins, including after errors or an abandoned close wait. Close may be retried; completed messages stay valid.

Provided Methods§

Source

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.

Source

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".

Implementors§