phantom-protocol 0.2.2

Post-quantum-secure L4/L6 universal transport framework — hybrid X25519+ML-KEM-768 / Ed25519+ML-DSA-65, multi-path, UniFFI bindings
Documentation
//! Phantom Protocol transport internals.
//!
//! The protocol layer beneath the public `crate::api` surface. PhantomUDP — a
//! QUIC-class reliable transport over raw UDP — is the production transport;
//! TCP / WebSocket / WASI / Embedded / TLS-mimicry byte-pipes also plug in via
//! `SessionTransport`. Key properties:
//! - Multi-streaming (independent streams, no head-of-line blocking)
//! - 0-RTT connection establishment (resumption + early-data)
//! - Seamless single-path connection migration (session survives IP changes)
//! - Adaptive fallback tiers (`Turbo → Reliable → Stealth`, see `fallback`)
//!
//! NOTE: multipath bandwidth aggregation / multi-homing was deliberately rejected
//! — migration moves one active path at a time, it does not bond paths. The
//! `scheduler` module is consequently vestigial.

// ── no_std-clean subset (Phase 3.6) ────────────────────────────────────
// `session_transport` and `legs::embedded` compile on bare-metal and are the
// only modules required for the embedded build.
pub mod legs;
pub mod session_transport;

// ── std-bound modules ──────────────────────────────────────────────────
// Everything below pulls `tokio`, `parking_lot`, `dashmap`, `arc-swap`,
// `std::sync::*`, `std::time::Instant`, raw sockets, or a std-bound crypto dep
// (`ring`, `ml-kem`, `ml-dsa`, `x25519-dalek`, `ed25519-dalek`).
// Gated behind `std`.
#[cfg(feature = "std")]
pub mod api;
#[cfg(feature = "std")]
pub mod bandwidth_estimator;
#[cfg(feature = "std")]
pub mod buffer_pool;
#[cfg(feature = "std")]
pub mod compression;
#[cfg(feature = "std")]
pub mod device_profile;
#[cfg(feature = "std")]
pub mod fallback;
#[cfg(feature = "std")]
pub mod fragmentation;
#[cfg(feature = "std")]
pub mod handshake;
#[cfg(feature = "std")]
pub mod liveness;
#[cfg(feature = "std")]
pub mod multiplexer;
#[cfg(feature = "std")]
pub mod pacer;
#[cfg(feature = "std")]
pub mod packet_coalescer;
#[cfg(feature = "std")]
pub mod packet_coalescer_codec;
#[cfg(feature = "std")]
pub mod path;
#[cfg(feature = "std")]
pub mod path_validation_codec;
#[cfg(feature = "std")]
pub mod reputation;
#[cfg(feature = "std")]
pub mod sack;
#[cfg(feature = "std")]
pub mod scheduler;
#[cfg(feature = "std")]
pub mod session;
#[cfg(feature = "std")]
pub mod session_cache;
#[cfg(feature = "std")]
pub mod shaping;
#[cfg(feature = "std")]
pub mod stream;
#[cfg(feature = "std")]
pub mod types;

// ── Native-only sub-modules (Phase 3.5) ────────────────────────────────
// These pull in `tokio::net::*` / raw sockets / libc and have no wasm
// equivalent. On wasm32 the corresponding functionality is provided
// either by `legs::WebSocketLeg` (transport) or by simply not being
// available (listening for incoming TCP — browsers cannot listen).
// All require `std`.
#[cfg(all(feature = "std", not(target_arch = "wasm32")))]
pub mod framing;
#[cfg(all(feature = "std", not(target_arch = "wasm32")))]
pub mod phantom_udp;
#[cfg(all(feature = "std", not(target_arch = "wasm32")))]
pub mod udp_transport;

// Re-exports for convenience
#[cfg(feature = "std")]
pub use fallback::{FallbackStateMachine, TransportMode};
#[cfg(feature = "std")]
pub use scheduler::Scheduler;
#[cfg(feature = "std")]
pub use session::Session;
#[cfg(feature = "std")]
pub use stream::Stream;
#[cfg(feature = "std")]
pub use types::*;