base_scheduler/socket_stream_writing.rs
1// Released under the MIT License.
2// Copyright, 2026, by Samuel Williams.
3
4use crate::{BufferPool, BufferPooling, IoBuf, SocketOperation, SocketStreamWriter};
5use std::io;
6
7/// Construct sequential stream output bound to this scheduler. Backends select a static writer without requiring protocols to choose registration or output-progress mechanisms. Construction performs no writes and rejects non-stream sockets.
8pub trait SocketStreamWriting: SocketOperation + BufferPooling {
9 /// Retain the socket and reusable backend state. Owned submissions accept this scheduler's pooled chunks, so the default reader and writer compose without choosing a buffer representation. Borrowed writes do not allocate a payload pool. Subsequent operations take only payloads and cancellation, never another scheduler.
10 fn socket_stream_writer<'scheduler>(
11 &'scheduler self,
12 socket: &Self::Socket,
13 ) -> io::Result<impl SocketStreamWriter<Buffer = <Self::Pool as BufferPool>::Buffer> + 'scheduler>
14 where
15 Self::Socket: 'static;
16
17 /// Select another stable owner type, such as `Vec<u8>` or an application lease. This changes storage compatibility, not the writer's ordering or backend execution strategy.
18 fn socket_stream_writer_with_buffer<'scheduler, B: IoBuf>(
19 &'scheduler self,
20 socket: &Self::Socket,
21 ) -> io::Result<impl SocketStreamWriter<Buffer = B> + 'scheduler>
22 where
23 Self::Socket: 'static;
24}