cubecl_environment/lib.rs
1#![no_std]
2#![warn(missing_docs)]
3
4//! # `CubeCL` Environment Library
5//!
6//! A cohesive API over the environment the code runs on: sync/std/thread,
7//! async/tokio, async/wasm and no-std.
8//!
9//! The crate is organized in pillars:
10//! - Compatibility shims mirroring `std` module names: [`sync`], [`collections`],
11//! [`time`], [`thread`], [`future`], plus [`rand`] and [`backtrace`].
12//! - [`stream`]: stream identity and policies, including tokio task-stable streams.
13//! - [`config`]: global configuration loading (`cubecl.toml` and friends).
14//! - [`persistence`]: key-value caches kept up to date in memory and synced to the
15//! file system (std), browser storage (wasm) or nothing (no-std).
16//! - [`bundle`]: named environment bundles that ship pre-warmed caches.
17
18#[cfg(feature = "std")]
19extern crate std;
20
21extern crate alloc;
22
23/// Synchronization primitives working across std, no-std and wasm environments.
24pub mod sync;
25
26/// Byte buffers with allocation properties, zero-copy views and optional
27/// memory-mapped backing. The type to use for byte payloads, never `Vec<u8>`.
28pub mod bytes;
29
30/// Hash map and set types with the environment's default hasher.
31pub mod collections;
32
33/// Time types working across std, wasm and embedded environments.
34pub mod time;
35
36/// Thread spawning, on the targets that have threads. Empty elsewhere: use
37/// [`future::spawn_detached`], which is portable.
38pub mod thread;
39
40/// Future utils with a compatible API for native, non-std and wasm environments.
41pub mod future;
42
43/// Rand module contains types for random number generation for non-std environments and for
44/// std environments.
45pub mod rand;
46
47/// Backtrace module to build error reports.
48pub mod backtrace;
49
50/// Stream identity, policies and manual stream management.
51pub mod stream;
52
53/// Named environments: the local store everything is warmed into, one active
54/// at a time.
55pub mod environment;
56
57/// Runtime configuration trait shared across crates.
58pub mod config;
59
60/// Key-value persistence: in-memory stores synced to the file system, browser
61/// storage or kept memory-only depending on the environment.
62pub mod persistence;
63
64/// Named environment bundles: ship pre-warmed autotune and compilation caches.
65pub mod bundle;