Expand description
Node API — the single public entry point for all truffle functionality.
The Node struct wires together Layers 3-6 and exposes a clean ~12-method
API that Layer 7 applications consume. Applications should never import
from lower layers directly; everything they need is accessible through Node.
§Quick start
ⓘ
use truffle_core::Node;
let node = Node::builder()
.name("my-app")
.sidecar_path("/usr/local/bin/truffle-sidecar")
.build()
.await?;
// Discover peers (Layer 3 — no transport needed)
let peers = node.peers().await;
// Send a namespaced message (Layer 6 envelope over Layer 4 WS).
// String args remain queries; RFC 022 Phase B adds Peer handles.
node.send(&peers[0].tailscale_id, "chat", b"hello!").await?;
// Subscribe to a namespace
let mut rx = node.subscribe("chat");
let msg = rx.recv().await?;
// Open a raw TCP stream (Layer 4 direct)
let stream = node.open_tcp(&peers[0].tailscale_id, 8080).await?;Structs§
- Namespaced
Message - A message received on a specific namespace.
- Node
- The main truffle node — single public entry point for all functionality.
- Node
Builder - Builder for constructing a
Node<TailscaleProvider>. - Peer
- A peer as seen by application code (RFC 022 projection).
Enums§
- Node
Error - Errors from the Node API.