workflow_core/
lib.rs

1//!
2//! [<img alt="github" src="https://img.shields.io/badge/github-workflow--rs-8da0cb?style=for-the-badge&labelColor=555555&color=8da0cb&logo=github" height="20">](https://github.com/workflow-rs/workflow-rs)
3//! [<img alt="crates.io" src="https://img.shields.io/crates/v/workflow-core.svg?maxAge=2592000&style=for-the-badge&color=fc8d62&logo=rust" height="20">](https://crates.io/crates/workflow-core)
4//! [<img alt="docs.rs" src="https://img.shields.io/badge/docs.rs-workflow--core-56c2a5?maxAge=2592000&style=for-the-badge&logo=docs.rs" height="20">](https://docs.rs/workflow-core)
5//! <img alt="license" src="https://img.shields.io/crates/l/workflow-core.svg?maxAge=2592000&color=6ac&style=for-the-badge&logoColor=fff" height="20">
6//! <img src="https://img.shields.io/badge/platform- native-informational?style=for-the-badge&color=50a0f0" height="20">
7//! <img src="https://img.shields.io/badge/platform- wasm32/browser -informational?style=for-the-badge&color=50a0f0" height="20">
8//! <img src="https://img.shields.io/badge/platform- wasm32/node.js -informational?style=for-the-badge&color=50a0f0" height="20">
9//! <img src="https://img.shields.io/badge/platform- solana_os/ignored-informational?style=for-the-badge&color=777787" height="20">
10//!
11//! [`workflow_core`] is a part of the [`workflow-rs`](https://crates.io/workflow-rs)
12//! framework, subset of which is designed to function uniformly across multiple
13//! environments including native Rust, WASM-browser and Solana OS targets.
14//!
15//! This is a general-purpose crate that provides platform-uniform (native and WASM) abstractions for:
16//! - async channels
17//! - task spawn, sleep and interval functions
18//! - random identifiers
19//! - async-friendly and thread-safe event triggers
20//! - time (Instant and Duration) as well as functions to obtain UNIX time (native and WASM)
21//! - yield_executor() function to yield Rust executor to browser using `requestAnimationFrame()` (this prevents async Rust applications from locking down the Browser UX)
22//! - runtime auto detection, allowing to identify the operating environment at runtime
23//! - home and data folder access (useful when combined with `workflow_store` crate)
24
25extern crate self as workflow_core;
26
27pub mod abortable;
28pub mod enums;
29pub mod extensions;
30pub mod prelude;
31pub mod runtime;
32pub mod sendable;
33pub mod utils;
34
35#[cfg(feature = "version")]
36pub mod version;
37
38#[cfg(not(target_arch = "wasm32"))]
39mod native;
40mod wasm;
41
42#[cfg(not(target_arch = "wasm32"))]
43pub mod fd;
44
45/// Seal macro that prevents accidental modification of the enclosed source code
46/// by hashing the source code and comparing it to the supplied hash.  If the code
47/// is modified, the macro will fail to compile, and the developer will need to
48/// change the hash value.  This is useful for locking down sensitive parts of the
49/// code to prevent their accidental change.
50pub use workflow_core_macros::seal;
51
52cfg_if::cfg_if! {
53
54
55    if #[cfg(not(target_arch = "bpf"))] {
56        // Generic 8-byte identifier
57        pub mod id;
58        // task re-exports and shims
59        pub mod task;
60        // channel re-exports and shims
61        pub mod channel;
62        // async object lookup combinator
63        pub mod lookup;
64        // time functions and utilities
65        pub mod time;
66        // environment variable access (native and Node.js abstraction)
67        pub mod env;
68        // Directory access (home folder, data folder) (native and Node.js abstraction)
69        pub mod dirs;
70        /// Trigger crate re-exports and shims
71        pub mod trigger;
72        // hex serialization traits
73        pub mod hex;
74        /// Re-export of [`mod@cfg_if`] crate.
75        pub use ::cfg_if::cfg_if;
76    }
77}