Skip to main content

SocketPacketWriter

Trait SocketPacketWriter 

Source
pub trait SocketPacketWriter: Send {
    // Required methods
    fn write(
        &mut self,
        buffer: &[u8],
        address: Option<SocketAddress>,
        cancellation: &Cancellation,
    ) -> impl Future<Output = OperationResult<usize>> + Send;
    fn write_vectored(
        &mut self,
        buffers: &[IoSlice<'_>],
        address: Option<SocketAddress>,
        cancellation: &Cancellation,
    ) -> impl Future<Output = OperationResult<usize>> + Send;
    fn write_owned<B: IoBuf>(
        &mut self,
        buffer: B,
        address: Option<SocketAddress>,
        cancellation: &Cancellation,
    ) -> impl Future<Output = BufferResult<B>> + Send;
    fn write_vectored_with_flags(
        &mut self,
        buffers: &[IoSlice<'_>],
        address: Option<SocketAddress>,
        flags: SocketSendFlags,
        cancellation: &Cancellation,
    ) -> impl Future<Output = OperationResult<usize>> + Send;
    fn write_owned_vectored<Buffers: IoBufSequence>(
        &mut self,
        buffers: Buffers,
        address: Option<SocketAddress>,
        flags: SocketSendFlags,
        cancellation: &Cancellation,
    ) -> impl Future<Output = (OperationResult<usize>, Buffers)> + Send;
    fn close(&mut self) -> impl Future<Output = Result<()>> + Send;

    // Provided method
    fn write_with_flags(
        &mut self,
        buffer: &[u8],
        address: Option<SocketAddress>,
        flags: SocketSendFlags,
        cancellation: &Cancellation,
    ) -> impl Future<Output = OperationResult<usize>> + Send { ... }
}
Expand description

Sequential packet sends through a fixed execution service. Every write is one send attempt, including empty packets; it never splits a packet into separate sends. None uses the connected peer.

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

Source

fn write( &mut self, buffer: &[u8], address: Option<SocketAddress>, cancellation: &Cancellation, ) -> impl Future<Output = OperationResult<usize>> + Send

Source

fn write_vectored( &mut self, buffers: &[IoSlice<'_>], address: Option<SocketAddress>, cancellation: &Cancellation, ) -> impl Future<Output = OperationResult<usize>> + Send

Send the vectors as one packet, preserving their order without advancing them. The returned count is the backend’s single-transfer result.

Source

fn write_owned<B: IoBuf>( &mut self, buffer: B, address: Option<SocketAddress>, cancellation: &Cancellation, ) -> impl Future<Output = BufferResult<B>> + Send

Retain the owner while sending one packet and return it on success, error, or cancellation. Abandonment drops the owner only after all borrowed access has ended.

Source

fn write_vectored_with_flags( &mut self, buffers: &[IoSlice<'_>], address: Option<SocketAddress>, flags: SocketSendFlags, cancellation: &Cancellation, ) -> impl Future<Output = OperationResult<usize>> + Send

Perform one borrowed vectored transfer with explicit flags. Vectors are never advanced implicitly; a short result leaves their ranges unchanged.

Source

fn write_owned_vectored<Buffers: IoBufSequence>( &mut self, buffers: Buffers, address: Option<SocketAddress>, flags: SocketSendFlags, cancellation: &Cancellation, ) -> impl Future<Output = (OperationResult<usize>, 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 writing and await registration retirement without cancellation. Stop using the writer when close begins; retry close after errors or abandonment to establish retirement.

Provided Methods§

Source

fn write_with_flags( &mut self, buffer: &[u8], address: Option<SocketAddress>, flags: SocketSendFlags, cancellation: &Cancellation, ) -> impl Future<Output = OperationResult<usize>> + Send

Perform one borrowed transfer with explicit portable flags. Payload access ends before each poll returns; successful progress is returned in that poll.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§