Expand description
§truffle
P2P mesh networking for your devices, built on Tailscale.
This is the convenience crate that bundles truffle-core (the Rust library)
and truffle-sidecar (auto-downloaded Go binary). For most users, this is
the only dependency you need.
§Quick start
[dependencies]
truffle = "0.3"use truffle::{Node, sidecar_path};
use truffle::network::tailscale::TailscaleProvider;
let node = Node::<TailscaleProvider>::builder()
.name("my-app")
.sidecar_path(sidecar_path())
.build()
.await?;
// Send a message to all peers
node.broadcast("chat", b"hello!").await;
// Subscribe to messages
let mut rx = node.subscribe("chat");§Advanced: BYO sidecar
If you want to manage the sidecar binary yourself, depend on truffle-core
directly:
[dependencies]
truffle-core = "0.3"Modules§
- envelope
- Layer 6: Envelope — Namespace-routed message framing.
- file_
transfer - File transfer subsystem for truffle-core.
- identity
- Identity and namespacing primitives (RFC 017).
- network
- Layer 3: Network — Peer discovery, addressing, encrypted tunnels.
- node
- Node API — the single public entry point for all truffle functionality.
- request_
reply - Request/reply utility for correlated message exchange.
- session
- Layer 5: Session — Peer identity, connection lifecycle, message routing.
- synced_
store - SyncedStore — device-owned state synchronization across the mesh.
- transport
- Layer 4: Transport — Protocol-specific connection management.
Structs§
- AppId
- An application identifier that defines the namespace two nodes must share in order to see each other as peers.
- Device
Id - A stable per-device identifier, formatted as a 26-character Crockford base32 ULID.
- Device
Name - A human-readable device name supplied by the user.
- Envelope
- A namespace-routed message. All application messages use this format over WebSocket connections. truffle-core NEVER inspects the payload.
- File
Backend - File-backed persistence. Each device slice is stored as a JSON file at
{base_dir}/{store_id}/{device_id}.json. - File
Offer - An incoming file offer from a remote peer.
- File
Transfer - File transfer handle — the public API for file transfers.
- Memory
Backend - In-memory backend (no persistence). Default.
- 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>. - Offer
Responder - One-shot responder for an incoming file offer.
- Peer
- A peer as seen by application code.
- Slice
- A versioned slice of data owned by a single device.
- Synced
Store - A synchronized key-value store with device-owned slices.
- Transfer
Progress - Progress update for an in-flight file transfer.
- Transfer
Result - Result of a completed file transfer.
Enums§
- File
Transfer Event - Events emitted by the file transfer subsystem.
- FtMessage
- File transfer signaling message types (sent via WS namespace “ft”).
- Identity
Error - Errors produced when parsing identifier inputs.
- Node
Error - Errors from the Node API.
- Offer
Decision - The application’s decision on a file offer.
- Request
Error - Errors returned by
send_and_wait. - Store
Event - Events emitted by a
SyncedStore. - Sync
Message - Wire protocol messages sent on namespace
"ss:{store_id}". - Transfer
Direction - Direction of a file transfer.
- Transfer
Error - Errors during file transfer.
Traits§
- Store
Backend - Backend for persisting store data across restarts.
Functions§
- send_
and_ wait - Send a namespaced message and wait for a reply that matches a predicate.
- sidecar_
path - Returns the path to the truffle sidecar binary.
- sidecar_
version - Returns the version of the bundled sidecar.
- slug
- Produce a Tailscale-safe slug from a raw device-name string, fitting
within
budgetASCII characters. - tailscale_
hostname - Compose the final Tailscale hostname
truffle-{app_id}-{slug}.