confium_net_tcp/lib.rs
1#![allow(rustdoc::broken_intra_doc_links)]
2#![allow(rustdoc::bare_urls)]
3#![allow(rustdoc::redundant_explicit_links)]
4#![allow(rustdoc::private_intra_doc_links)]
5#![allow(rustdoc::invalid_html_tags)]
6
7//! TCP transport for Confium.
8//!
9//! `tcp://host:port` URLs address a peer reachable over a plain TCP
10//! socket. A [`TcpListener`] bound via `tcp://0.0.0.0:port` (or any
11//! loopback / interface address) accepts inbound connections and yields
12//! [`TcpTransport`] handles on [`confium_net::Listener::accept`].
13//!
14//! The transport wraps [`std::net::TcpStream`] /
15//! [`std::net::TcpListener`] and frames each `send`/`recv` pair as one
16//! length-prefixed message so the [`confium_net::Transport`] contract —
17//! one `send` observed as one `recv` payload — holds over a byte-stream
18//! socket. (Raw TCP does not preserve message boundaries; a 4-byte
19//! big-endian length prefix does.)
20//!
21//! See `TODO.roadmap/05-networking-primitives.md` for the design and
22//! the `confium_net` crate for the trait definitions.
23//!
24//! # Schemes
25//!
26//! - `tcp` — accept either IPv4 or IPv6 addresses.
27//! - `tcp4` — restrict to IPv4 literals.
28//! - `tcp6` — restrict to IPv6 literals.
29
30pub mod listener;
31pub mod transport;
32
33pub use listener::TcpListener;
34pub use transport::TcpTransport;
35pub use transport::TcpTransportKind;
36
37use confium_net::register_transport;
38
39// One kind owns all three schemes, mirroring how the built-in
40// `InprocKind` owns the `inproc` scheme. `register_transport!` submits
41// it to the link-time inventory so `confium_net::connect` /
42// `confium_net::listen` can dispatch to it by scheme.
43register_transport!(TcpTransportKind);