base-scheduler 0.3.1

Explicit, runtime-independent scheduler capabilities for protocol libraries
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// Released under the MIT License.
// Copyright, 2026, by Samuel Williams.

use super::SocketOperation;
use std::{
    io,
    net::{TcpListener, TcpStream},
};

/// Optional interoperability with existing standard-library TCP resources. Streams and listeners become the same backend socket descriptor. Register once; the backend sets the nonblocking mode it needs. Do not change that mode through another handle. Simulated schedulers need not implement it.
pub trait SocketRegistration: SocketOperation {
    /// Take ownership of a connected standard-library TCP stream and return it as this scheduler's socket.
    fn register_socket(&self, socket: TcpStream) -> io::Result<Self::Socket>;
    /// Take ownership of a standard-library TCP listener and return it as this scheduler's socket.
    fn register_listener(&self, listener: TcpListener) -> io::Result<Self::Socket>;
}