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 /// Construct a packet writer for `socket` without performing payload I/O. Stream sockets are rejected.
14 fn socket_packet_writer<'scheduler>(
15 &'scheduler self,
16 socket: &Self::Socket,
17 ) -> io::Result<impl SocketPacketWriter + 'scheduler + use<'scheduler, Self>>
18 where
19 Self: Sized,
20 Self::Socket: 'static;
21}