saorsa_core/lib.rs
1// Copyright 2024 Saorsa Labs Limited
2//
3// This software is dual-licensed under:
4// - GNU Affero General Public License v3.0 or later (AGPL-3.0-or-later)
5// - Commercial License
6//
7// For AGPL-3.0 license, see LICENSE-AGPL-3.0
8// For commercial licensing, contact: david@saorsalabs.com
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under these licenses is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
14// Enforce no unwrap/expect/panic in production code only (tests can use them)
15#![cfg_attr(not(test), warn(clippy::unwrap_used))]
16#![cfg_attr(not(test), warn(clippy::expect_used))]
17#![cfg_attr(not(test), warn(clippy::panic))]
18// Allow unused_async as many functions are async for API consistency
19#![allow(clippy::unused_async)]
20
21//! # Saorsa Core
22//!
23//! A next-generation peer-to-peer networking foundation built in Rust.
24//!
25//! ## Features
26//!
27//! - QUIC-based transport with NAT traversal
28//! - IPv4-first with simple addressing
29//! - Kademlia DHT for distributed routing
30//! - Post-quantum cryptography (ML-DSA-65, ML-KEM-768)
31
32#![allow(missing_docs)]
33#![allow(missing_debug_implementations)]
34#![warn(rust_2018_idioms)]
35
36// Conditional logging macros (compile to nothing in release builds).
37// `#[macro_use]` makes these macros available throughout the crate without imports.
38// Not `#[macro_export]` — these are internal-only, not part of the public API.
39#[macro_use]
40mod logging;
41
42// Internal modules — used by the crate but not exposed publicly.
43pub(crate) mod adaptive;
44pub(crate) mod address;
45pub(crate) mod bgp_geo_provider;
46pub(crate) mod bootstrap;
47pub(crate) mod dht;
48pub(crate) mod dht_network_manager;
49pub(crate) mod error;
50pub(crate) mod network;
51pub(crate) mod quantum_crypto;
52pub(crate) mod rate_limit;
53pub(crate) mod security;
54pub(crate) mod transport;
55pub(crate) mod transport_handle;
56pub(crate) mod validation;
57
58/// User identity and privacy system (public — accessed via path by saorsa-node).
59pub mod identity;
60
61// ---------------------------------------------------------------------------
62// Public re-exports — only items that saorsa-node consumes.
63// ---------------------------------------------------------------------------
64
65// Networking
66pub use address::MultiAddr;
67pub use network::{NodeConfig, NodeMode, P2PEvent, P2PNode};
68
69// Bootstrap
70pub use bootstrap::{BootstrapConfig, BootstrapManager, BootstrapStats};
71
72// Trust & Adaptive DHT
73pub use adaptive::dht::{AdaptiveDhtConfig, TrustEvent};
74pub use adaptive::trust::TrustEngine;
75
76// Security
77pub use security::IPDiversityConfig;
78
79// Post-quantum cryptography
80pub use quantum_crypto::MlDsa65;
81
82// Canonical peer identity (also accessible via identity::peer_id::PeerId)
83pub use identity::peer_id::PeerId;
84
85// ---------------------------------------------------------------------------
86// Crate-internal re-exports — used by sibling modules via `crate::Result` etc.
87// ---------------------------------------------------------------------------
88pub(crate) use error::{P2PError, P2pResult as Result};
89
90/// Default capacity for broadcast and mpsc event channels throughout the system.
91pub(crate) const DEFAULT_EVENT_CHANNEL_CAPACITY: usize = 1000;