1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//! # truffle-core
//!
//! Clean architecture rebuild of truffle's core networking library.
//!
//! This crate implements the layered architecture described in RFC 012:
//! - **Layer 3 (Network)**: Peer discovery, addressing, encrypted tunnels via Tailscale
//! - **Layer 4 (Transport)**: WebSocket, TCP, QUIC protocol transports
//! - **Layer 5 (Session)**: Peer registry, lazy connections, message routing
//! - **Layer 6 (Envelope)**: Namespace-based message framing
//! - **Node API**: Single public entry point wiring all layers together
//!
//! ## Quick start
//!
//! ```ignore
//! use truffle_core::{Node, NodeBuilder};
//!
//! let node = Node::builder()
//! .name("my-app")
//! .sidecar_path("/usr/local/bin/truffle-sidecar")
//! .build()
//! .await?;
//!
//! let peers = node.peers().await;
//! node.send(&peers[0].id, "chat", b"hello!").await?;
//! ```
//!
//! ## Layer 3 — Network
//!
//! The [`NetworkProvider`](network::NetworkProvider) trait defines a generic interface for peer
//! discovery and raw connectivity. The [`TailscaleProvider`](network::tailscale::TailscaleProvider)
//! implementation wraps the Go sidecar (tsnet) to provide encrypted Tailscale tunnels.
//!
//! ## Layer 4 — Transport
//!
//! Three transport trait families sit on top of Layer 3:
//!
//! - [`StreamTransport`](transport::StreamTransport) + [`FramedStream`](transport::FramedStream):
//! Message-oriented bidirectional connections (WebSocket, future QUIC streams).
//! - [`RawTransport`](transport::RawTransport): Raw byte streams (TCP).
//! - [`DatagramTransport`](transport::DatagramTransport): Unreliable datagrams (future UDP/QUIC).
//!
//! ## Layer 5 — Session
//!
//! The [`PeerRegistry`](session::PeerRegistry) manages peer state and WebSocket connections.
//! Peers exist in the registry when Layer 3 discovers them, even before any transport
//! connections are established.
//!
//! ## Layer 6 — Envelope
//!
//! The [`Envelope`] struct wraps all application messages with a namespace string
//! for routing and an opaque JSON payload that truffle-core never inspects.
//!
//! ## Node API
//!
//! The [`Node`] struct is the single public entry point. It exposes ~12 methods
//! covering discovery, messaging, raw streams, and diagnostics.
// Re-export the main public types for convenience.
pub use Envelope;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;