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
//! # 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
//!
//! ```toml
//! [dependencies]
//! truffle = "0.4"
//! ```
//!
//! ```rust,no_run
//! use truffle::{Node, sidecar_path};
//! use truffle::network::tailscale::TailscaleProvider;
//!
//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
//! let node = Node::<TailscaleProvider>::builder()
//! .app_id("my-app")?
//! .device_name("my-device")
//! .sidecar_path(sidecar_path())
//! .build()
//! .await?;
//!
//! // Send a message to all peers
//! node.broadcast_json("chat", &serde_json::json!({ "text": "hello!" }))
//! .await?;
//!
//! // Subscribe to messages
//! let mut rx = node.subscribe("chat");
//! # Ok(())
//! # }
//! ```
//!
//! ## Advanced: BYO sidecar
//!
//! If you want to manage the sidecar binary yourself, depend on `truffle-core`
//! directly:
//!
//! ```toml
//! [dependencies]
//! truffle-core = "0.4"
//! ```
// Re-export everything from truffle-core
pub use *;
/// Returns the path to the truffle sidecar binary.
///
/// This uses the build-time downloaded binary from `truffle-sidecar`.
/// Override with `TRUFFLE_SIDECAR_PATH` environment variable.
/// Returns the version of the bundled sidecar.