logicaffeine_system/lib.rs
1#![cfg_attr(docsrs, feature(doc_cfg))]
2
3//! Platform IO and System Services for LOGOS
4//!
5//! This crate provides platform-specific IO operations with feature-gated heavy dependencies.
6//!
7//! ## Feature Flags (Cerf/Drasner Amendment)
8//!
9//! - (default): Lean build with basic IO only
10//! - `networking`: P2P networking via libp2p (large dependency)
11//! - `persistence`: File persistence with memmap2 (small dependency)
12//! - `concurrency`: Parallel computation with rayon (moderate dependency)
13//! - `full`: All features enabled
14//! - `distributed`: networking + persistence (for Distributed<T>)
15
16// === Always Available (Core IO) ===
17pub mod io;
18
19// Native-only core modules
20#[cfg(not(target_arch = "wasm32"))]
21pub mod time;
22#[cfg(not(target_arch = "wasm32"))]
23pub mod env;
24#[cfg(not(target_arch = "wasm32"))]
25pub mod random;
26
27// === Feature-Gated Modules ===
28
29// Persistence feature: file operations, storage, VFS
30#[cfg(feature = "persistence")]
31pub mod file;
32#[cfg(feature = "persistence")]
33pub mod fs;
34#[cfg(feature = "persistence")]
35pub mod storage;
36
37// Networking feature: P2P networking
38#[cfg(feature = "networking")]
39pub mod network;
40
41// Concurrency feature: parallel computation
42#[cfg(feature = "concurrency")]
43pub mod concurrency;
44#[cfg(feature = "concurrency")]
45pub mod memory;
46
47// Distributed<T> requires both networking AND persistence
48#[cfg(all(feature = "networking", feature = "persistence"))]
49pub mod distributed;
50
51// CRDT sync wrapper requires networking (uses tokio + libp2p)
52#[cfg(feature = "networking")]
53pub mod crdt;
54
55// Re-export tokio for async main support (native only)
56#[cfg(not(target_arch = "wasm32"))]
57pub use tokio;
58
59// Re-export commonly used items
60pub use io::{show, read_line, println, eprintln, print, Showable};
61
62/// Panic with a custom message (used by generated LOGOS code)
63pub fn panic_with(reason: &str) -> ! {
64 panic!("{}", reason);
65}
66
67/// Formatting utilities
68pub mod fmt {
69 pub fn format<T: std::fmt::Display>(x: T) -> String {
70 format!("{}", x)
71 }
72}