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;
18pub mod temporal;
19
20// Native-only core modules
21#[cfg(not(target_arch = "wasm32"))]
22pub mod time;
23#[cfg(not(target_arch = "wasm32"))]
24pub mod env;
25#[cfg(not(target_arch = "wasm32"))]
26pub mod random;
27
28// === Feature-Gated Modules ===
29
30// Persistence feature: file operations, storage, VFS
31#[cfg(feature = "persistence")]
32pub mod file;
33#[cfg(feature = "persistence")]
34pub mod fs;
35#[cfg(feature = "persistence")]
36pub mod storage;
37
38// Networking feature: P2P networking
39#[cfg(feature = "networking")]
40pub mod network;
41
42// Concurrency feature: parallel computation
43#[cfg(feature = "concurrency")]
44pub mod concurrency;
45#[cfg(feature = "concurrency")]
46pub mod memory;
47
48// Distributed<T> requires both networking AND persistence
49#[cfg(all(feature = "networking", feature = "persistence"))]
50pub mod distributed;
51
52// CRDT sync wrapper requires networking (uses tokio + libp2p)
53#[cfg(feature = "networking")]
54pub mod crdt;
55
56// Re-export tokio for async main support (native only)
57#[cfg(not(target_arch = "wasm32"))]
58pub use tokio;
59
60// Re-export commonly used items
61pub use io::{show, read_line, println, eprintln, print, Showable};
62pub use temporal::{LogosDate, LogosMoment, LogosSpan};
63
64/// Panic with a custom message (used by generated LOGOS code)
65pub fn panic_with(reason: &str) -> ! {
66 panic!("{}", reason);
67}
68
69/// Formatting utilities
70pub mod fmt {
71 pub fn format<T: std::fmt::Display>(x: T) -> String {
72 format!("{}", x)
73 }
74}