Skip to main content

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