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
81
82
83
84
85
//! # federation-net
//!
//! A generic peer-to-peer networking engine built on [Iroh](https://iroh.computer).
//!
//! The library establishes direct (NAT-traversing, relay-assisted) QUIC
//! connections between peers and exchanges typed, application-defined
//! messages over them. It deliberately contains no domain logic: the
//! application chooses its own message type and the engine treats it as an
//! opaque, serde-serializable payload.
//!
//! ## Core concepts
//!
//! * [`NetworkId`] — isolates independent P2P networks from each other.
//! * [`SchemaId`] — isolates applications with incompatible message schemas.
//! * [`PeerTicket`] — a shareable string invitation used to reach a peer.
//! * [`RendezvousConfig`] — optional automatic peer discovery: peers of a
//! network find each other through the BitTorrent Mainline DHT knowing
//! nothing but the network id.
//! * [`NetworkEngine`] — the engine itself; [`NetworkEventReceiver`] delivers
//! [`NetworkEvent`]s to the application.
//!
//! ## Example
//!
//! ```no_run
//! use federation_net::{NetworkConfig, NetworkEngine, NetworkId, SchemaId};
//!
//! #[derive(Debug, serde::Serialize, serde::Deserialize)]
//! enum MyMessage {
//! Hello { from: String },
//! }
//!
//! # async fn run() -> federation_net::Result<()> {
//! let config = NetworkConfig::builder()
//! .data_dir("./peer-a")
//! .network_id(NetworkId::from_name("example-network"))
//! .schema_id(SchemaId::from_name("my-message-v1"))
//! .build()?;
//!
//! let (engine, mut events) = NetworkEngine::<MyMessage>::start(config).await?;
//! let ticket = engine.ticket().await?;
//! println!("share this ticket: {ticket}");
//!
//! while let Some(event) = events.recv().await {
//! println!("{event:?}");
//! }
//! engine.shutdown().await?;
//! # Ok(())
//! # }
//! ```
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use RENDEZVOUS_RECORD_VERSION;
pub use ;
pub use ;
// Re-exported Iroh types that appear in the public API.
pub use ;
pub use ;
// Re-exported so applications can use the generic ticket helpers.
pub use Ticket;