saorsa_core/
lib.rs

1// Copyright 2024 MaidSafe 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: saorsalabs@gmail.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//! # Saorsa Core
15//! 
16//! A next-generation peer-to-peer networking foundation built in Rust.
17//! 
18//! ## Features
19//! 
20//! - QUIC-based transport for modern networking
21//! - IPv6-first with comprehensive tunneling support
22//! - Kademlia DHT for distributed routing
23//! - Built-in MCP server for AI capabilities
24//! - Minimal dependencies and small footprint
25//! 
26//! ## Example
27//! 
28//! ```rust,no_run
29//! use saorsa_core::{P2PNode, NodeConfig};
30//! 
31//! #[tokio::main]
32//! async fn main() -> anyhow::Result<()> {
33//!     let node = P2PNode::builder()
34//!         .listen_on("/ip6/::/tcp/9000")
35//!         .with_mcp_server()
36//!         .build()
37//!         .await?;
38//!     
39//!     node.run().await?;
40//!     Ok(())
41//! }
42//! ```
43
44#![warn(missing_docs)]
45#![warn(rust_2018_idioms)]
46
47/// Network core functionality
48pub mod network;
49
50/// Distributed Hash Table implementation
51pub mod dht;
52
53/// DHT Network Integration Manager
54pub mod dht_network_manager;
55
56/// Transport layer (QUIC, TCP)
57pub mod transport;
58
59/// IPv6/IPv4 tunneling protocols
60pub mod tunneling;
61
62/// Model Context Protocol server
63pub mod mcp;
64
65/// Security and cryptography
66pub mod security;
67
68/// User identity and privacy system
69pub mod identity;
70
71/// DHT-based storage for multi-device sync
72pub mod storage;
73
74/// Chat system (Slack-like)
75pub mod chat;
76
77/// Discuss system (Discourse-like)
78pub mod discuss;
79
80/// Projects system with hierarchical organization
81pub mod projects;
82
83/// Threshold cryptography for group operations
84pub mod threshold;
85
86/// Quantum-resistant cryptography
87pub mod quantum_crypto;
88
89/// Utility functions and types
90pub mod utils;
91
92/// Production hardening features
93pub mod production;
94
95/// Bootstrap cache for decentralized peer discovery
96pub mod bootstrap;
97
98/// Error types
99pub mod error;
100
101// Re-export main types
102pub use network::{P2PNode, NodeConfig, NodeBuilder, P2PEvent};
103pub use dht::{Key, Record};
104pub use dht_network_manager::{DhtNetworkManager, DhtNetworkConfig, DhtNetworkOperation, DhtNetworkResult, DhtNetworkEvent, DhtPeerInfo, BootstrapNode};
105pub use mcp::{MCPServer, Tool, MCPService};
106pub use production::{ProductionConfig, ResourceManager, ResourceMetrics};
107pub use bootstrap::{BootstrapManager, BootstrapCache, ContactEntry, CacheConfig};
108pub use error::{P2PError, Result};
109
110// Enhanced identity exports
111#[cfg(feature = "quantum-resistant")]
112pub use identity::enhanced::{
113    EnhancedIdentity, EnhancedIdentityManager, Organization, 
114    Department, Team, Permission,
115};
116
117// Storage exports
118pub use storage::{StorageManager, FileChunker}; // SyncManager temporarily disabled
119
120// Chat exports
121pub use chat::{
122    Channel, ChannelId, Message, MessageId, Thread, 
123    ChatManager, ChannelType, Call,
124};
125
126// Discuss exports
127pub use discuss::{
128    Category, CategoryId, Topic, TopicId, Reply, ReplyId,
129    DiscussManager, Poll, Badge, UserStats,
130};
131
132// Projects exports
133pub use projects::{
134    Project, ProjectId, Document, DocumentId, Folder,
135    ProjectsManager, WorkflowState, ProjectAnalytics,
136};
137
138// Threshold exports
139pub use threshold::{
140    ThresholdGroup, ThresholdSignature,
141    ThresholdGroupManager, ParticipantInfo, GroupMetadata,
142};
143
144// Quantum crypto exports for types used by threshold
145pub use quantum_crypto::types::{GroupId, ParticipantId};
146
147// Placeholder types (will be replaced with actual libp2p types)
148/// Peer identifier used throughout Saorsa
149/// 
150/// Currently implemented as a String for simplicity, but will be replaced
151/// with proper libp2p PeerId type in future versions.
152pub type PeerId = String;
153
154/// Multiaddress used for network addressing
155/// 
156/// Currently implemented as a String for simplicity, but will be replaced  
157/// with proper libp2p Multiaddr type in future versions.
158pub type Multiaddr = String;
159
160/// Saorsa Core version
161pub const VERSION: &str = env!("CARGO_PKG_VERSION");
162
163#[cfg(test)]
164mod tests {
165    use super::*;
166    
167    #[test]
168    fn test_version() {
169        assert!(!VERSION.is_empty());
170    }
171}