rune/
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"><img alt="crates.io" src="https://img.shields.io/crates/v/rune.svg?style=for-the-badge&color=fc8d62&logo=rust" height="20"></a>
5//! <a href="https://docs.rs/rune"><img alt="docs.rs" src="https://img.shields.io/badge/docs.rs-rune-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.81+</b>.
9//! <br>
10//! <br>
11//! <a href="https://rune-rs.github.io"><b>Visit the site 🌐</b></a>
12//! &mdash;
13//! <a href="https://rune-rs.github.io/book/"><b>Read the book 📖</b></a>
14//! <br>
15//! <br>
16//!
17//! The Rune Language, an embeddable dynamic programming language for Rust.
18//!
19//! <br>
20//!
21//! ## Contributing
22//!
23//! If you want to help out, please have a look at [Open Issues].
24//!
25//! <br>
26//!
27//! ## Highlights of Rune
28//!
29//! * Runs a compact representation of the language on top of an efficient
30//!   [stack-based virtual machine][support-virtual-machine].
31//! * Clean [Rust integration 💻][support-rust-integration].
32//! * [Multithreaded 📖][support-multithreading] execution.
33//! * [Hot reloading 📖][support-hot-reloading].
34//! * Memory safe through [reference counting 📖][support-reference-counted].
35//! * [Awesome macros 📖][support-macros] and [Template literals 📖][support-templates].
36//! * [Try operators 📖][support-try] and [Pattern matching 📖][support-patterns].
37//! * [Structs and enums 📖][support-structs] with associated data and
38//!   functions.
39//! * Dynamic containers like [vectors 📖][support-dynamic-vectors], [objects
40//!   📖][support-anon-objects], and [tuples 📖][support-anon-tuples] all with
41//!   out-of-the-box [serde support 💻][support-serde].
42//! * First-class [async support 📖][support-async] with [Generators 📖][support-generators].
43//! * Dynamic [instance functions 📖][support-instance-functions].
44//! * [Stack isolation 📖][support-stack-isolation] between function calls.
45//!
46//! <br>
47//!
48//! ## Rune scripts
49//!
50//! You can run Rune programs with the bundled CLI:
51//!
52//! ```text
53//! cargo run --bin rune -- run scripts/hello_world.rn
54//! ```
55//!
56//! If you want to see detailed diagnostics of your program while it's running,
57//! you can use:
58//!
59//! ```text
60//! cargo run --bin rune -- run scripts/hello_world.rn --dump --trace
61//! ```
62//!
63//! See `--help` for more information.
64//!
65//! <br>
66//!
67//! ## Running scripts from Rust
68//!
69//! > You can find more examples [in the `examples` folder].
70//!
71//! The following is a complete example, including rich diagnostics using
72//! [`termcolor`]. It can be made much simpler if this is not needed.
73//!
74//! [`termcolor`]: https://docs.rs/termcolor
75//!
76//! ```no_run
77//! use rune::{Context, Diagnostics, Source, Sources, Vm};
78//! use rune::termcolor::{ColorChoice, StandardStream};
79//! use std::sync::Arc;
80//!
81//! let context = Context::with_default_modules()?;
82//! let runtime = Arc::new(context.runtime()?);
83//!
84//! let mut sources = Sources::new();
85//! sources.insert(Source::memory("pub fn add(a, b) { a + b }")?);
86//!
87//! let mut diagnostics = Diagnostics::new();
88//!
89//! let result = rune::prepare(&mut sources)
90//!     .with_context(&context)
91//!     .with_diagnostics(&mut diagnostics)
92//!     .build();
93//!
94//! if !diagnostics.is_empty() {
95//!     let mut writer = StandardStream::stderr(ColorChoice::Always);
96//!     diagnostics.emit(&mut writer, &sources)?;
97//! }
98//!
99//! let unit = result?;
100//! let mut vm = Vm::new(runtime, Arc::new(unit));
101//!
102//! let output = vm.call(["add"], (10i64, 20i64))?;
103//! let output: i64 = rune::from_value(output)?;
104//!
105//! println!("{}", output);
106//! # Ok::<_, rune::support::Error>(())
107//! ```
108//!
109//! [in the `examples` folder]: https://github.com/rune-rs/rune/tree/main/examples/examples
110//! [Open Issues]: https://github.com/rune-rs/rune/issues
111//! [support-anon-objects]: https://rune-rs.github.io/book/objects.html
112//! [support-anon-tuples]: https://rune-rs.github.io/book/tuples.html
113//! [support-async]: https://rune-rs.github.io/book/async.html
114//! [support-dynamic-vectors]: https://rune-rs.github.io/book/vectors.html
115//! [support-generators]: https://rune-rs.github.io/book/generators.html
116//! [support-hot-reloading]: https://rune-rs.github.io/book/hot_reloading.html
117//! [support-instance-functions]: https://rune-rs.github.io/book/instance_functions.html
118//! [support-macros]: https://rune-rs.github.io/book/macros.html
119//! [support-multithreading]: https://rune-rs.github.io/book/multithreading.html
120//! [support-patterns]: https://rune-rs.github.io/book/pattern_matching.html
121//! [support-reference-counted]: https://rune-rs.github.io/book/variables.html
122//! [support-rust-integration]: https://github.com/rune-rs/rune/tree/main/crates/rune-modules
123//! [support-serde]: https://github.com/rune-rs/rune/blob/main/crates/rune-modules/src/json.rs
124//! [support-stack-isolation]: https://rune-rs.github.io/book/call_frames.html
125//! [support-structs]: https://rune-rs.github.io/book/structs.html
126//! [support-templates]: https://rune-rs.github.io/book/template_literals.html
127//! [support-try]: https://rune-rs.github.io/book/try_operator.html
128//! [support-virtual-machine]: https://rune-rs.github.io/book/the_stack.html
129
130#![no_std]
131#![deny(missing_docs)]
132#![deny(rustdoc::broken_intra_doc_links)]
133#![deny(rustdoc::private_doc_tests)]
134#![cfg_attr(rune_nightly, feature(rustdoc_missing_doc_code_examples))]
135#![cfg_attr(rune_nightly, deny(rustdoc::missing_doc_code_examples))]
136#![allow(clippy::enum_variant_names)]
137#![allow(clippy::needless_doctest_main)]
138#![allow(clippy::too_many_arguments)]
139#![allow(clippy::should_implement_trait)]
140#![allow(clippy::branches_sharing_code)]
141#![allow(clippy::match_like_matches_macro)]
142#![allow(clippy::type_complexity)]
143#![allow(clippy::module_inception)]
144#![allow(clippy::self_named_constructors)]
145#![cfg_attr(rune_docsrs, feature(doc_cfg))]
146
147#[cfg(feature = "std")]
148#[macro_use]
149extern crate std;
150
151// This is here for forward compatibility when we can support allocation-free
152// execution.
153#[cfg(not(feature = "alloc"))]
154compile_error!("The `alloc` feature is currently required to build rune, but will change for parts of rune in the future.");
155
156#[macro_use]
157extern crate alloc as rust_alloc;
158
159/// A macro that can be used to construct a [Span][crate::ast::Span] that can be
160/// pattern matched over.
161///
162/// # Examples
163///
164/// ```
165/// use rune::ast::Span;
166/// use rune::span;
167///
168/// let span = Span::new(42, 84);
169/// assert!(matches!(span, span!(42, 84)));
170/// ```
171#[macro_export]
172#[doc(hidden)]
173macro_rules! span {
174    ($start:expr, $end:expr) => {
175        $crate::ast::Span {
176            start: $crate::ast::ByteIndex($start),
177            end: $crate::ast::ByteIndex($end),
178        }
179    };
180}
181
182pub mod alloc;
183
184/// Helper prelude for `#[no_std]` support.
185pub mod no_std;
186
187#[macro_use]
188mod internal_macros;
189
190#[macro_use]
191mod exported_macros;
192
193#[macro_use]
194pub mod ast;
195
196#[cfg(feature = "fmt")]
197pub mod fmt;
198
199#[cfg(feature = "emit")]
200#[cfg_attr(rune_docsrs, doc(cfg(feature = "emit")))]
201#[doc(inline)]
202pub use ::codespan_reporting::term::termcolor;
203
204pub(crate) mod any;
205pub use self::any::Any;
206
207mod build;
208pub use self::build::{prepare, Build, BuildError};
209
210pub mod compile;
211#[doc(inline)]
212pub use self::compile::{Context, ContextError, Options};
213
214pub mod item;
215#[doc(inline)]
216pub use self::item::{Item, ItemBuf};
217
218#[doc(hidden)]
219mod function_meta;
220
221mod function;
222
223pub mod module;
224#[doc(inline)]
225pub use self::module::module::Module;
226
227pub mod diagnostics;
228#[doc(inline)]
229pub use self::diagnostics::Diagnostics;
230
231pub mod hash;
232#[doc(inline)]
233pub use self::hash::{Hash, ToTypeHash};
234
235#[cfg(feature = "alloc")]
236mod hashbrown;
237
238mod params;
239pub use self::params::Params;
240
241mod hir;
242
243mod indexing;
244
245pub mod macros;
246
247pub mod modules;
248
249pub mod parse;
250
251pub(crate) mod grammar;
252
253pub mod query;
254
255pub mod runtime;
256#[doc(inline)]
257pub use self::runtime::{
258    from_const_value, from_value, to_const_value, to_value, FromValue, Mut, Ref, ToConstValue,
259    ToValue, TypeHash, Unit, Value, Vm,
260};
261
262mod shared;
263
264pub mod source;
265#[doc(inline)]
266pub use self::source::Source;
267
268#[macro_use]
269mod sources;
270#[doc(inline)]
271pub use self::sources::{SourceId, Sources};
272
273mod worker;
274
275#[doc(hidden)]
276pub mod support;
277
278#[cfg(feature = "workspace")]
279#[cfg_attr(rune_docsrs, doc(cfg(feature = "workspace")))]
280pub mod workspace;
281
282/// Macro used to annotate native functions which can be loaded into rune.
283///
284/// This macro automatically performs the following things:
285/// * Rust documentation comments are captured so that it can be used in
286///   generated Rune documentation.
287/// * The name of arguments is captured to improve documentation generation.
288/// * If an instance function is annotated this is detected (if the function
289///   receives `self`). This behavior can be forced using
290///   `#[rune::function(instance)]` if the function doesn't take `self`.
291/// * The name of the function can be set using the `#[rune::function(path =
292///   name)]` argument.
293/// * An associated function can be specified with the `#[rune::function(path =
294///   Type::name)]` argument. If `instance` is specified it is an associated
295///   instance function that can be defined externally.
296/// * Instance functions can be made a protocol function
297///   `#[rune::function(protocol = DISPLAY_FMT)]`.
298///
299/// # Instance and associated functions
300///
301/// Instance and associated functions are a bit tricky to declare using
302/// `#[rune::function]`, and care must be taken that you understand what needs
303/// to be done. So this section is dedicated to documenting the ins and outs of
304/// the process.
305///
306/// Briefly we should mention that instance functions are functions which are
307/// associated with a type at runtime. Calling a value like `value.hello()`
308/// invokes the `hello` associated function through the instance of `value`. The
309/// exact type of `value` will then be used to look up which function to call.
310/// They must take some kind of `self` parameter. Meanwhile associated functions
311/// are just functions which are associated with a static type. Like
312/// `String::new()`. The type `String` must then be in scope, and the function
313/// does not take a `self` parameter.
314///
315/// This is how you declare an instance function which takes `&self` or `&mut
316/// self`:
317///
318/// ```rust
319/// # use rune::Any;
320/// #[derive(Any)]
321/// struct Struct {
322///     /* .. */
323/// }
324///
325/// impl Struct {
326///     /// Get the length of the `Struct`.
327///     #[rune::function]
328///     fn len(&self) -> usize {
329///         /* .. */
330///         # todo!()
331///     }
332/// }
333/// ```
334///
335/// If a function does not take `&self` or `&mut self`, you must specify that
336/// it's an instance function using `#[rune::function(instance)]`. The first
337/// argument is then considered the instance the function gets associated with:
338///
339/// ```rust
340/// # use rune::Any;
341/// #[derive(Any)]
342/// struct Struct {
343///     /* .. */
344/// }
345///
346/// /// Get the length of the `Struct`.
347/// #[rune::function(instance)]
348/// fn len(this: &Struct) -> usize {
349///     /* .. */
350///     # todo!()
351/// }
352/// ```
353///
354/// To declare an associated function which does not receive the type we
355/// must specify the path to the function using `#[rune::function(path =
356/// Self::<name>)]`:
357///
358/// ```rust
359/// # use rune::Any;
360/// #[derive(Any)]
361/// struct Struct {
362///     /* .. */
363/// }
364///
365/// impl Struct {
366///     /// Construct a new [`Struct`].
367///     #[rune::function(path = Self::new)]
368///     fn new() -> Struct {
369///         Struct {
370///            /* .. */
371///         }
372///     }
373/// }
374/// ```
375///
376/// Or externally like this:
377///
378/// ```rust
379/// # use rune::Any;
380/// #[derive(Any)]
381/// struct Struct {
382///     /* .. */
383/// }
384///
385/// /// Construct a new [`Struct`].
386/// #[rune::function(free, path = Struct::new)]
387/// fn new() -> Struct {
388///     Struct {
389///        /* .. */
390///     }
391/// }
392/// ```
393///
394/// The first part `Struct` in `Struct::new` is used to determine the type
395/// the function is associated with.
396///
397/// Protocol functions can either be defined in an impl block or externally. To
398/// define a protocol externally, you can simply do this:
399///
400/// ```rust
401/// # use rune::Any;
402/// # use rune::runtime::{Formatter, VmResult};
403/// #[derive(Any)]
404/// struct Struct {
405///     /* .. */
406/// }
407///
408/// #[rune::function(instance, protocol = DISPLAY_FMT)]
409/// fn display_fmt(this: &Struct, f: &mut Formatter) -> VmResult<()> {
410///     /* .. */
411///     # todo!()
412/// }
413/// ```
414///
415/// # Examples
416///
417/// Defining and using a simple free function:
418///
419/// ```
420/// use rune::{Module, ContextError};
421///
422/// /// This is a pretty neat function which is called `std::str::to_uppercase("hello")`.
423/// #[rune::function]
424/// fn to_uppercase(string: &str) -> String {
425///     string.to_uppercase()
426/// }
427///
428/// fn module() -> Result<Module, ContextError> {
429///     let mut m = Module::new();
430///     m.function_meta(to_uppercase)?;
431///     Ok(m)
432/// }
433/// ```
434///
435/// A free instance function:
436///
437/// ```
438/// use rune::{Module, ContextError};
439///
440/// /// This is a pretty neat function, which is called like `"hello".to_uppercase()`.
441/// #[rune::function(instance)]
442/// fn to_uppercase(string: &str) -> String {
443///     string.to_uppercase()
444/// }
445///
446/// /// This is a pretty neat function, which is called like `string::to_uppercase2("hello")`.
447/// #[rune::function(path = string)]
448/// fn to_uppercase2(string: &str) -> String {
449///     string.to_uppercase()
450/// }
451///
452/// fn module() -> Result<Module, ContextError> {
453///     let mut m = Module::new();
454///     m.function_meta(to_uppercase)?;
455///     m.function_meta(to_uppercase2)?;
456///     Ok(m)
457/// }
458/// ```
459///
460/// Regular instance and protocol functions:
461///
462/// ```
463/// use rune::{Any, Module, ContextError};
464/// use rune::vm_write;
465/// use rune::runtime::{Formatter, VmResult};
466/// use rune::alloc::fmt::TryWrite;
467///
468/// #[derive(Any)]
469/// struct String {
470///     inner: std::string::String
471/// }
472///
473/// impl String {
474///     /// Construct a new string wrapper.
475///     #[rune::function(path = Self::new)]
476///     fn new(string: &str) -> Self {
477///         Self {
478///             inner: string.into()
479///         }
480///     }
481///
482///     /// Uppercase the string inside of the string wrapper.
483///     ///
484///     /// # Examples
485///     ///
486///     /// ```rune
487///     /// let string = String::new("hello");
488///     /// assert_eq!(string.to_uppercase(), "HELLO");
489///     /// ```
490///     #[rune::function]
491///     fn to_uppercase(&self) -> String {
492///         String {
493///             inner: self.inner.to_uppercase()
494///         }
495///     }
496///
497///     /// Display the string using the [`DISPLAY_FMT`] protocol.
498///     ///
499///     /// # Examples
500///     ///
501///     /// ```rune
502///     /// let string = String::new("hello");
503///     /// assert_eq!(format!("{}", string), "hello");
504///     /// ```
505///     #[rune::function(protocol = DISPLAY_FMT)]
506///     fn display(&self, f: &mut Formatter) -> VmResult<()> {
507///         vm_write!(f, "{}", self.inner);
508///         VmResult::Ok(())
509///     }
510/// }
511///
512/// /// Construct a new empty string.
513/// ///
514/// /// # Examples
515/// ///
516/// /// ```rune
517/// /// let string = String::empty();
518/// /// assert_eq!(string, "hello");
519/// /// ```
520/// #[rune::function(free, path = String::empty)]
521/// fn empty() -> String {
522///     String {
523///         inner: std::string::String::new()
524///     }
525/// }
526///
527/// /// Lowercase the string inside of the string wrapper.
528/// ///
529/// /// # Examples
530/// ///
531/// /// ```rune
532/// /// let string = String::new("Hello");
533/// /// assert_eq!(string.to_lowercase(), "hello");
534/// /// ```
535/// #[rune::function(instance)]
536/// fn to_lowercase(this: &String) -> String {
537///     String {
538///         inner: this.inner.to_lowercase()
539///     }
540/// }
541///
542/// fn module() -> Result<Module, ContextError> {
543///     let mut m = Module::new();
544///     m.ty::<String>()?;
545///     m.function_meta(String::new)?;
546///     m.function_meta(empty)?;
547///     m.function_meta(String::to_uppercase)?;
548///     m.function_meta(to_lowercase)?;
549///     m.function_meta(String::display)?;
550///     Ok(m)
551/// }
552/// ```
553///
554/// # Using `vm_result` and `<expr>.vm?`.
555///
556/// In order to conveniently deal with virtual machine errors which require use
557/// [`VmResult`] this attribute macro supports the `vm_result` option.
558///
559/// This changes the return value of the function to be [`VmResult`], and
560/// ensures that any try operator use is wrapped as appropriate. The special
561/// operator `<expr>.vm?` is also supported in this context, which is a
562/// shorthand for the [`vm_try!`] macro.
563///
564/// ```
565/// use rune::alloc::String;
566/// use rune::alloc::prelude::*;
567///
568/// #[rune::function(vm_result)]
569/// fn trim(string: &str) -> String {
570///     string.trim().try_to_owned().vm?
571/// }
572/// ```
573///
574/// This can be combined with regular uses of the try operator `?`:
575///
576/// ```
577/// use core::str::Utf8Error;
578///
579/// use rune::alloc::String;
580/// use rune::alloc::prelude::*;
581///
582/// #[rune::function(vm_result)]
583/// fn trim_bytes(bytes: &[u8]) -> Result<String, Utf8Error> {
584///     Ok(core::str::from_utf8(bytes)?.trim().try_to_owned().vm?)
585/// }
586/// ```
587///
588/// # Using `keep` to keep the name
589///
590/// By default, the name of the function is mangled and the metadata is given
591/// the original name. This means you can't easily call the function from both
592/// Rune and Rust. This behaviour can be changed by using the `keep` attribute, in
593/// which case you must refer to the meta object by a mangled name
594/// (specifically the function name with `__meta` appended):
595///
596/// ```
597/// use rune::{Module, ContextError};
598///
599/// /// Don't mangle the name of the function
600/// #[rune::function(keep)]
601/// fn to_uppercase(string: &str) -> String {
602///     string.to_uppercase()
603/// }
604///
605/// fn module() -> Result<Module, ContextError> {
606///     let mut m = Module::new();
607///     m.function_meta(to_uppercase__meta)?;
608///     Ok(m)
609/// }
610///
611/// fn call_from_rust() {
612///    assert_eq!(to_uppercase("hello"), "HELLO");
613/// }
614/// ```
615///
616/// [`VmResult`]: crate::runtime::VmResult
617/// [`vm_try!`]: crate::vm_try!
618pub use rune_macros::function;
619
620/// Macro used to annotate native functions which can be loaded as macros in
621/// rune.
622///
623/// See [`Module::macro_meta`].
624#[doc(hidden)]
625pub use rune_macros::macro_;
626
627/// Macro used to annotate native functions which can be loaded as attribute
628/// macros in rune.
629///
630/// See [`Module::macro_meta`].
631#[doc(hidden)]
632pub use rune_macros::attribute_macro;
633
634/// Macro used to annotate a module with metadata.
635///
636/// ThIs defines a local function `module_meta` which can be used in conjunction
637/// with [`Module::from_meta`] to construct a module with a given item and
638/// captured documentation.
639#[doc(inline)]
640pub use rune_macros::module;
641
642#[doc(inline)]
643pub use rune_macros::hash;
644
645#[doc(inline)]
646pub(crate) use rune_macros::hash_in;
647
648pub use rune_macros::item;
649
650#[cfg(feature = "cli")]
651mod ace;
652
653#[cfg(feature = "cli")]
654#[cfg_attr(rune_docsrs, doc(cfg(feature = "cli")))]
655pub mod cli;
656
657#[cfg(feature = "languageserver")]
658pub mod languageserver;
659
660#[cfg(feature = "doc")]
661#[cfg_attr(rune_docsrs, doc(cfg(feature = "doc")))]
662pub(crate) mod doc;
663
664/// Privately exported details.
665#[doc(hidden)]
666pub mod __private {
667    pub use crate::any::AnyMarker;
668    pub use crate::function_meta::{
669        FunctionMetaData, FunctionMetaKind, FunctionMetaStatics, MacroMetaData, MacroMetaKind,
670    };
671    pub use crate::item::ItemBuf;
672    pub use crate::module::{InstallWith, Module, ModuleMetaData};
673    pub use crate::params::Params;
674    pub use crate::runtime::{TypeHash, TypeOf};
675    pub use rust_alloc::boxed::Box;
676    pub use rust_alloc::sync::Arc;
677}
678
679mod musli;
680mod serde;
681
682#[cfg(test)]
683mod tests;
684
685rune_macros::binding! {
686    impl ::std::string::String for crate::alloc::String;
687    #[cfg(feature = "std")]
688    #[cfg_attr(rune_docsrs, doc(cfg(feature = "std")))]
689    impl ::std::io::Error for std::io::Error;
690    #[cfg(feature = "alloc")]
691    #[cfg_attr(rune_docsrs, doc(cfg(feature = "alloc")))]
692    impl ::std::string::FromUtf8Error for crate::alloc::string::FromUtf8Error;
693    impl ::std::error::Error for anyhow::Error;
694    impl ::std::fmt::Error for core::fmt::Error;
695    impl ::std::char::ParseCharError for core::char::ParseCharError;
696    impl ::std::num::ParseFloatError for core::num::ParseFloatError;
697    impl ::std::num::ParseIntError for core::num::ParseIntError;
698    impl ::std::string::Utf8Error for core::str::Utf8Error;
699    #[any]
700    impl ::std::option::Option for Option<Value>;
701    #[type_of]
702    impl<T> ::std::option::Option for Option<T>;
703    #[any]
704    impl ::std::result::Result for Result<Value, Value>;
705    #[type_of]
706    impl<T, E> ::std::result::Result for Result<T, E>;
707    #[type_of]
708    impl ::std::bool for bool;
709    #[type_of]
710    impl ::std::char for char;
711    #[type_of]
712    impl ::std::i64 for i8;
713    #[type_of]
714    impl ::std::i64 for i16;
715    #[type_of]
716    impl ::std::i64 for i32;
717    #[type_of]
718    impl ::std::i64 for i64;
719    #[type_of]
720    impl ::std::i64 for i128;
721    #[type_of]
722    impl ::std::i64 for isize;
723    #[type_of]
724    impl ::std::u64 for u8;
725    #[type_of]
726    impl ::std::u64 for u16;
727    #[type_of]
728    impl ::std::u64 for u32;
729    #[type_of]
730    impl ::std::u64 for u64;
731    #[type_of]
732    impl ::std::u64 for u128;
733    #[type_of]
734    impl ::std::u64 for usize;
735    #[type_of]
736    impl ::std::f64 for f32;
737    #[type_of]
738    impl ::std::f64 for f64;
739    #[type_of]
740    impl<C, B> ::std::ops::ControlFlow for core::ops::ControlFlow<C, B>;
741    #[type_of]
742    impl ::std::bytes::Bytes for [u8];
743    #[type_of]
744    impl ::std::cmp::Ordering for core::cmp::Ordering;
745    #[type_of]
746    #[cfg(feature = "alloc")]
747    #[cfg_attr(rune_docsrs, doc(cfg(feature = "alloc")))]
748    #[type_of]
749    impl ::std::string::String for ::rust_alloc::string::String;
750    #[type_of]
751    impl ::std::string::String for crate::alloc::Box<str>;
752    #[type_of]
753    impl ::std::string::String for str;
754    #[type_of]
755    impl ::std::vec::Vec for [Value];
756    #[type_of]
757    #[cfg(feature = "alloc")]
758    #[cfg_attr(rune_docsrs, doc(cfg(feature = "alloc")))]
759    #[type_of]
760    impl<T> ::std::vec::Vec for ::rust_alloc::vec::Vec<T>;
761    #[type_of]
762    impl<T> ::std::vec::Vec for crate::alloc::Vec<T>;
763    #[type_of]
764    impl<T> ::std::vec::Vec for crate::runtime::VecTuple<T>;
765    #[type_of]
766    impl ::std::tuple::Tuple for crate::runtime::Tuple;
767    #[type_of]
768    impl<T> ::std::object::Object for crate::alloc::HashMap<::rust_alloc::string::String, T>;
769    #[type_of]
770    impl<T> ::std::object::Object for crate::alloc::HashMap<alloc::String, T>;
771    #[type_of]
772    #[cfg(feature = "std")]
773    #[cfg_attr(rune_docsrs, doc(cfg(feature = "std")))]
774    impl<T> ::std::object::Object for std::collections::HashMap<::rust_alloc::string::String, T>;
775    #[type_of]
776    #[cfg(feature = "std")]
777    #[cfg_attr(rune_docsrs, doc(cfg(feature = "std")))]
778    impl<T> ::std::object::Object for std::collections::HashMap<alloc::String, T>;
779    #[type_of]
780    impl ::std::any::Type for crate::runtime::Type;
781    #[type_of]
782    impl ::std::any::Hash for crate::hash::Hash;
783}