Skip to main content

phantom_protocol/transport/
mod.rs

1//! Phantom Protocol transport internals.
2//!
3//! The protocol layer beneath the public `crate::api` surface. PhantomUDP — a
4//! QUIC-class reliable transport over raw UDP — is the production transport;
5//! TCP / WebSocket / WASI / Embedded / TLS-mimicry byte-pipes also plug in via
6//! `SessionTransport`. Key properties:
7//! - Multi-streaming (independent streams, no head-of-line blocking)
8//! - 0-RTT connection establishment (resumption + early-data)
9//! - Seamless single-path connection migration (session survives IP changes)
10//! - Adaptive fallback tiers (`Turbo → Reliable → Stealth`, see `fallback`)
11//!
12//! NOTE: multipath bandwidth aggregation / multi-homing was deliberately rejected
13//! — migration moves one active path at a time, it does not bond paths. The
14//! `scheduler` module is consequently vestigial.
15
16// ── no_std-clean subset (Phase 3.6) ────────────────────────────────────
17// `session_transport` and `legs::embedded` compile on bare-metal and are the
18// only modules required for the embedded build.
19pub mod legs;
20pub mod session_transport;
21
22// ── std-bound modules ──────────────────────────────────────────────────
23// Everything below pulls `tokio`, `parking_lot`, `dashmap`, `arc-swap`,
24// `std::sync::*`, `std::time::Instant`, raw sockets, or a std-bound crypto dep
25// (`ring`, `ml-kem`, `ml-dsa`, `x25519-dalek`, `ed25519-dalek`).
26// Gated behind `std`.
27#[cfg(feature = "std")]
28pub mod api;
29#[cfg(feature = "std")]
30pub mod bandwidth_estimator;
31#[cfg(feature = "std")]
32pub mod buffer_pool;
33#[cfg(feature = "std")]
34pub mod compression;
35#[cfg(feature = "std")]
36pub mod device_profile;
37#[cfg(feature = "std")]
38pub mod fallback;
39#[cfg(feature = "std")]
40pub mod fragmentation;
41#[cfg(feature = "std")]
42pub mod handshake;
43#[cfg(feature = "std")]
44pub mod liveness;
45#[cfg(feature = "std")]
46pub mod multiplexer;
47#[cfg(feature = "std")]
48pub mod pacer;
49#[cfg(feature = "std")]
50pub mod packet_coalescer;
51#[cfg(feature = "std")]
52pub mod packet_coalescer_codec;
53#[cfg(feature = "std")]
54pub mod path;
55#[cfg(feature = "std")]
56pub mod path_validation_codec;
57#[cfg(feature = "std")]
58pub mod reputation;
59#[cfg(feature = "std")]
60pub mod sack;
61#[cfg(feature = "std")]
62pub mod scheduler;
63#[cfg(feature = "std")]
64pub mod session;
65#[cfg(feature = "std")]
66pub mod session_cache;
67#[cfg(feature = "std")]
68pub mod shaping;
69#[cfg(feature = "std")]
70pub mod stream;
71#[cfg(feature = "std")]
72pub mod types;
73
74// ── Native-only sub-modules (Phase 3.5) ────────────────────────────────
75// These pull in `tokio::net::*` / raw sockets / libc and have no wasm
76// equivalent. On wasm32 the corresponding functionality is provided
77// either by `legs::WebSocketLeg` (transport) or by simply not being
78// available (listening for incoming TCP — browsers cannot listen).
79// All require `std`.
80#[cfg(all(feature = "std", not(target_arch = "wasm32")))]
81pub mod framing;
82#[cfg(all(feature = "std", not(target_arch = "wasm32")))]
83pub mod phantom_udp;
84#[cfg(all(feature = "std", not(target_arch = "wasm32")))]
85pub mod udp_transport;
86
87// Re-exports for convenience
88#[cfg(feature = "std")]
89pub use fallback::{FallbackStateMachine, TransportMode};
90#[cfg(feature = "std")]
91pub use scheduler::Scheduler;
92#[cfg(feature = "std")]
93pub use session::Session;
94#[cfg(feature = "std")]
95pub use stream::Stream;
96#[cfg(feature = "std")]
97pub use types::*;