Skip to main content

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//! - [`records`]: what an environment remembers of how it was built.
18
19#[cfg(feature = "std")]
20extern crate std;
21
22extern crate alloc;
23
24/// Synchronization primitives working across std, no-std and wasm environments.
25pub mod sync;
26
27/// Byte buffers with allocation properties, zero-copy views and optional
28/// memory-mapped backing. The type to use for byte payloads, never `Vec<u8>`.
29pub mod bytes;
30
31/// Hash map and set types with the environment's default hasher.
32pub mod collections;
33
34/// Time types working across std, wasm and embedded environments.
35pub mod time;
36
37/// Thread spawning, on the targets that have threads. Empty elsewhere: use
38/// [`future::spawn_detached`], which is portable.
39pub mod thread;
40
41/// Future utils with a compatible API for native, non-std and wasm environments.
42pub mod future;
43
44/// Rand module contains types for random number generation for non-std environments and for
45/// std environments.
46pub mod rand;
47
48/// Backtrace module to build error reports.
49pub mod backtrace;
50
51/// Stream identity, policies and manual stream management.
52pub mod stream;
53
54/// Named environments: the local store everything is warmed into, one active
55/// at a time.
56pub mod environment;
57
58/// Runtime configuration trait shared across crates.
59pub mod config;
60
61/// Key-value persistence: in-memory stores synced to the file system, browser
62/// storage or kept memory-only depending on the environment.
63pub mod persistence;
64
65/// Named environment bundles: ship pre-warmed autotune and compilation caches.
66pub mod bundle;
67
68pub mod records;