Skip to main content

base_scheduler/
socket_packet_writing.rs

1// Released under the MIT License.
2// Copyright, 2026, by Samuel Williams.
3
4use crate::{SocketOperation, SocketPacketWriter};
5use std::io;
6
7/// Construct sequential packet output bound to this scheduler. Separate reader and writer handles permit concurrent reception and sending; backends can choose their own static writer.
8///
9/// The returned handle may borrow the scheduler, but never the temporary socket
10/// reference. It retains backend access independently, so the socket and handle
11/// can move together. Retire and drop handles before exclusively closing the socket.
12pub trait SocketPacketWriting: SocketOperation {
13    fn socket_packet_writer<'scheduler>(
14        &'scheduler self,
15        socket: &Self::Socket,
16    ) -> io::Result<impl SocketPacketWriter + 'scheduler + use<'scheduler, Self>>
17    where
18        Self: Sized,
19        Self::Socket: 'static;
20}