Skip to main content

hyprstream_p2p/
lib.rs

1//! GitTorrent - Decentralized Git hosting over iroh-blobs + a mainline locator.
2//!
3//! The object plane (`put_object`/`get_object`) is backed by iroh-blobs with a
4//! mainline (BEP5) DHT rendezvous locator (F1–F3, epic #880 Track F). The old
5//! libp2p Kademlia stack was retired in F3 (#901).
6
7pub mod blobs;
8pub mod crypto;
9pub mod daemon;
10pub mod error;
11pub mod git;
12pub mod service;
13pub mod types;
14
15/// at9p mainline (BEP5) locator — see #889 / epic #880 Track C.
16pub mod locator;
17
18// Re-export commonly used types
19pub use error::{Error, Result};
20pub use types::*;
21
22// Re-export transport functionality for consuming applications
23pub use git::transport::{
24    register_gittorrent_transport, GittorrentTransportFactory, TransportFactory,
25};
26
27/// Library version
28pub const VERSION: &str = env!("CARGO_PKG_VERSION");
29
30/// Initialize tracing for the library
31pub fn init_tracing() -> Result<()> {
32    use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
33
34    tracing_subscriber::registry()
35        .with(
36            tracing_subscriber::EnvFilter::try_from_default_env()
37                .unwrap_or_else(|_| "hyprstream-p2p=info".into()),
38        )
39        .with(tracing_subscriber::fmt::layer())
40        .try_init()
41        .map_err(|_| Error::other("Tracing already initialized"))
42}
43
44#[cfg(test)]
45mod tests {
46    use super::*;
47
48    #[test]
49    #[allow(clippy::const_is_empty)]
50    fn test_version() {
51        // VERSION comes from CARGO_PKG_VERSION and is always non-empty
52        assert!(!VERSION.is_empty());
53    }
54}