rune_modules/lib.rs
1//! <img alt="rune logo" src="https://raw.githubusercontent.com/rune-rs/rune/main/assets/icon.png" />
2//! <br>
3//! <a href="https://github.com/rune-rs/rune"><img alt="github" src="https://img.shields.io/badge/github-rune--rs/rune-8da0cb?style=for-the-badge&logo=github" height="20"></a>
4//! <a href="https://crates.io/crates/rune-modules"><img alt="crates.io" src="https://img.shields.io/crates/v/rune-modules.svg?style=for-the-badge&color=fc8d62&logo=rust" height="20"></a>
5//! <a href="https://docs.rs/rune-modules"><img alt="docs.rs" src="https://img.shields.io/badge/docs.rs-rune--modules-66c2a5?style=for-the-badge&logoColor=white&logo=data:image/svg+xml;base64,PHN2ZyByb2xlPSJpbWciIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDUxMiA1MTIiPjxwYXRoIGZpbGw9IiNmNWY1ZjUiIGQ9Ik00ODguNiAyNTAuMkwzOTIgMjE0VjEwNS41YzAtMTUtOS4zLTI4LjQtMjMuNC0zMy43bC0xMDAtMzcuNWMtOC4xLTMuMS0xNy4xLTMuMS0yNS4zIDBsLTEwMCAzNy41Yy0xNC4xIDUuMy0yMy40IDE4LjctMjMuNCAzMy43VjIxNGwtOTYuNiAzNi4yQzkuMyAyNTUuNSAwIDI2OC45IDAgMjgzLjlWMzk0YzAgMTMuNiA3LjcgMjYuMSAxOS45IDMyLjJsMTAwIDUwYzEwLjEgNS4xIDIyLjEgNS4xIDMyLjIgMGwxMDMuOS01MiAxMDMuOSA1MmMxMC4xIDUuMSAyMi4xIDUuMSAzMi4yIDBsMTAwLTUwYzEyLjItNi4xIDE5LjktMTguNiAxOS45LTMyLjJWMjgzLjljMC0xNS05LjMtMjguNC0yMy40LTMzLjd6TTM1OCAyMTQuOGwtODUgMzEuOXYtNjguMmw4NS0zN3Y3My4zek0xNTQgMTA0LjFsMTAyLTM4LjIgMTAyIDM4LjJ2LjZsLTEwMiA0MS40LTEwMi00MS40di0uNnptODQgMjkxLjFsLTg1IDQyLjV2LTc5LjFsODUtMzguOHY3NS40em0wLTExMmwtMTAyIDQxLjQtMTAyLTQxLjR2LS42bDEwMi0zOC4yIDEwMiAzOC4ydi42em0yNDAgMTEybC04NSA0Mi41di03OS4xbDg1LTM4Ljh2NzUuNHptMC0xMTJsLTEwMiA0MS40LTEwMi00MS40di0uNmwxMDItMzguMiAxMDIgMzguMnYuNnoiPjwvcGF0aD48L3N2Zz4K" height="20"></a>
6//! <a href="https://discord.gg/v5AeNkT"><img alt="chat on discord" src="https://img.shields.io/discord/558644981137670144.svg?logo=discord&style=flat-square" height="20"></a>
7//! <br>
8//! Minimum support: Rust <b>1.87+</b>.
9//! <br>
10//! <br>
11//! <a href="https://rune-rs.github.io"><b>Visit the site 🌐</b></a>
12//! —
13//! <a href="https://rune-rs.github.io/book/"><b>Read the book 📖</b></a>
14//! <br>
15//! <br>
16//!
17//! Native modules for Rune, an embeddable dynamic programming language for Rust.
18//!
19//! <br>
20//!
21//! ## Usage
22//!
23//! These are modules that can be used with the [Rune language].
24//!
25//! [Rune Language]: https://rune-rs.github.io
26//!
27//! See each module for documentation:
28//! * [base64]
29//! * [core]
30//! * [fmt]
31//! * [fs]
32//! * [http]
33//! * [io]
34//! * [json]
35//! * [macros]
36//! * [process]
37//! * [rand]
38//! * [signal]
39//! * [test]
40//! * [time]
41//! * [toml]
42//!
43//! <br>
44//!
45//! ## Features
46//!
47//! * `core` for the [core module][toml]
48//! * `fmt` for the [fmt module][fmt]
49//! * `fs` for the [fs module][fs]
50//! * `full` includes all modules.
51//! * `http` for the [http module][http]
52//! * `io` for the [io module][io]
53//! * `json` for the [json module][json]
54//! * `macros` for the [macros module][macros]
55//! * `process` for the [process module][process]
56//! * `rand` for the [rand module][rand]
57//! * `signal` for the [signal module][signal]
58//! * `test` for the [test module][test]
59//! * `time` for the [time module][time]
60//! * `toml` for the [toml module][toml]
61//!
62//! [core]: https://docs.rs/rune-modules/0/rune_modules/core/
63//! [fmt]: https://docs.rs/rune-modules/0/rune_modules/fmt/
64//! [fs]: https://docs.rs/rune-modules/0/rune_modules/fs/
65//! [http]: https://docs.rs/rune-modules/0/rune_modules/http/
66//! [io]: https://docs.rs/rune-modules/0/rune_modules/io/
67//! [json]: https://docs.rs/rune-modules/0/rune_modules/json/
68//! [macros]: https://docs.rs/rune-modules/0/rune_modules/macros/
69//! [process]: https://docs.rs/rune-modules/0/rune_modules/process/
70//! [rand]: https://docs.rs/rune-modules/0/rune_modules/rand/
71//! [signal]: https://docs.rs/rune-modules/0/rune_modules/signal/
72//! [test]: https://docs.rs/rune-modules/0/rune_modules/test/
73//! [time]: https://docs.rs/rune-modules/0/rune_modules/time/
74//! [toml]: https://docs.rs/rune-modules/0/rune_modules/toml/
75
76// Note: The above links to docs.rs are needed because cargo-readme does not
77// support intra-doc links (yet):
78// https://github.com/livioribeiro/cargo-readme/issues/55
79
80macro_rules! entry {
81 ($({$ident:ident, $name:literal $(, $module:ident)*}),* $(,)?) => {
82 /// Construct a a default rune context with all enabled modules provided
83 /// based on the [default rune
84 /// context](rune::Context::with_default_modules).
85 pub fn with_config(stdio: bool) -> Result<rune::Context, rune::ContextError> {
86 #[allow(unused_mut)]
87 let mut context = rune::Context::with_config(stdio)?;
88
89 $(
90 #[allow(deprecated)]
91 #[cfg(feature = $name)]
92 {
93 context.install(self::$ident::module(stdio)?)?;
94 $(context.install(self::$ident::$module::module(stdio)?)?;)*
95 }
96 )*
97
98 Ok(context)
99 }
100
101 /// Construct a a default context rune context with default config.
102 pub fn default_context() -> Result<rune::Context, rune::ContextError> {
103 with_config(true)
104 }
105 }
106}
107
108#[cfg(feature = "base64")]
109pub mod base64;
110
111#[cfg(feature = "fs")]
112pub mod fs;
113
114#[cfg(feature = "http")]
115pub mod http;
116
117#[cfg(feature = "json")]
118pub mod json;
119
120#[cfg(feature = "process")]
121pub mod process;
122
123#[cfg(feature = "rand")]
124pub mod rand;
125
126#[cfg(feature = "signal")]
127pub mod signal;
128
129#[cfg(feature = "test")]
130pub mod test;
131
132#[cfg(feature = "time")]
133pub mod time;
134
135#[cfg(feature = "toml")]
136pub mod toml;
137
138entry! {
139 {base64, "base64"},
140 {fs, "fs"},
141 {http, "http"},
142 {json, "json"},
143 {process, "process"},
144 {rand, "rand"},
145 {signal, "signal"},
146 {test, "test"},
147 {time, "time"},
148 {toml, "toml", ser, de},
149}