kitsune2/lib.rs
1//! Kitsune2 - 2nd generation peer-to-peer communication framework.
2//!
3//! This is the top-level crate of the Kitsune2 framework. It only contains a
4//! production builder for creating instances using the factory pattern. The
5//! individual components of Kitsune2 provide more information about its functionality
6//! and types.
7//!
8//! Kitsune2 is the reference implementation of the [Kitsune2 API](kitsune2_api)
9//!
10//! [DHT](https://docs.rs/kitsune2_dht/latest/kitsune2_dht/)
11//! [Gossip protocol](https://github.com/holochain/kitsune2/blob/main/crates/gossip/README.md)
12//! [Bootstrap server](https://docs.rs/kitsune2_bootstrap_srv/latest/kitsune2_bootstrap_srv/)
13//! [Core modules](kitsune2_core)
14
15use kitsune2_api::*;
16use kitsune2_core::{
17 Ed25519Verifier,
18 factories::{self, MemOpStoreFactory},
19};
20use kitsune2_gossip::K2GossipFactory;
21#[cfg(all(
22 not(feature = "transport-tx5-backend-go-pion"),
23 feature = "transport-iroh"
24))]
25use kitsune2_transport_iroh::IrohTransportFactory;
26#[cfg(feature = "transport-tx5-backend-go-pion")]
27use kitsune2_transport_tx5::Tx5TransportFactory;
28
29/// Construct a default production builder for Kitsune2.
30///
31/// - `verifier` - The default verifier is [Ed25519Verifier].
32/// - `kitsune` - The default top-level kitsune module is [factories::CoreKitsuneFactory].
33/// - `space` - The default space module is [factories::CoreSpaceFactory].
34/// - `peer_store` - The default peer store is [factories::MemPeerStoreFactory].
35/// - `bootstrap` - The default bootstrap is [factories::CoreBootstrapFactory].
36/// - `fetch` - The default fetch module is [factories::CoreFetchFactory].
37/// - `report` - The default report module is [factories::CoreReportFactory].
38/// - `transport` - The default transport is [kitsune2_transport_iroh::IrohTransportFactory].
39/// - `op_store` - The default op store is [MemOpStoreFactory].
40/// Note: you will likely want to implement your own op store.
41/// - `peer_meta_store` - The default peer meta store is [factories::MemPeerMetaStoreFactory].
42/// Note: you will likely want to implement your own peer meta store.
43/// - `gossip` - The default gossip module is [K2GossipFactory].
44/// - `local_agent_store` - The default local agent store is [factories::CoreLocalAgentStoreFactory].
45/// - `publish` - The default publish module is [factories::CorePublishFactory].
46/// - `blocks` - The default blocks module is [factories::MemBlocksFactory].
47/// Note: you will likely want to implement your own [`Blocks`] module.
48pub fn default_builder() -> Builder {
49 Builder {
50 config: Config::default(),
51 verifier: std::sync::Arc::new(Ed25519Verifier),
52 auth_material_bootstrap: None,
53 auth_material_relay: None,
54 kitsune: factories::CoreKitsuneFactory::create(),
55 space: factories::CoreSpaceFactory::create(),
56 peer_store: factories::MemPeerStoreFactory::create(),
57 bootstrap: factories::CoreBootstrapFactory::create(),
58 fetch: factories::CoreFetchFactory::create(),
59 report: factories::CoreReportFactory::create(),
60 #[cfg(feature = "transport-tx5-backend-go-pion")]
61 transport: Tx5TransportFactory::create(),
62 #[cfg(all(
63 not(feature = "transport-tx5-backend-go-pion"),
64 feature = "transport-iroh"
65 ))]
66 transport: IrohTransportFactory::create(),
67 op_store: MemOpStoreFactory::create(),
68 peer_meta_store: factories::MemPeerMetaStoreFactory::create(),
69 gossip: K2GossipFactory::create(),
70 local_agent_store: factories::CoreLocalAgentStoreFactory::create(),
71 publish: factories::CorePublishFactory::create(),
72 blocks: factories::MemBlocksFactory::create(),
73 }
74}