1#![allow(unknown_lints)]
7#![allow(clippy::needless_lifetimes)]
8#![allow(clippy::uninlined_format_args)]
9#![allow(mismatched_lifetime_syntaxes)]
10#![cfg_attr(feature = "doc-cfg", feature(doc_cfg))]
11#![allow(clippy::doc_lazy_continuation)]
12#![cfg_attr(not(test), no_std)]
13
14#[doc(hidden)]
15pub extern crate alloc;
16
17#[cfg(any(feature = "std", test))]
18extern crate std;
19
20pub(crate) use alloc::string::String as StdString;
21pub(crate) use core::result::Result as StdResult;
22
23mod js_lifetime;
24pub mod markers;
25mod persistent;
26mod result;
27mod safe_ref;
28mod util;
29mod value;
30pub(crate) use safe_ref::*;
31pub mod runtime;
32pub use runtime::Runtime;
33pub mod context;
34pub use context::{Context, Ctx};
35pub mod class;
36pub use class::Class;
37pub use js_lifetime::JsLifetime;
38pub use persistent::Persistent;
39pub use result::{CatchResultExt, CaughtError, CaughtResult, Error, Result, ThrowResultExt};
40pub use value::{
41 array, atom, convert, function, module, object, promise, Array, Atom, BigInt, CString, Coerced,
42 Exception, Filter, FromAtom, FromIteratorJs, FromJs, Function, IntoAtom, IntoJs, IteratorJs,
43 Module, Null, Object, Promise, String, Symbol, Type, Undefined, Value, WriteOptions,
44 WriteOptionsEndianness,
45};
46
47pub mod allocator;
48#[cfg(feature = "loader")]
49#[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "loader")))]
50pub mod loader;
51
52#[cfg(feature = "futures")]
53#[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "futures")))]
54pub use context::AsyncContext;
55#[cfg(feature = "multi-ctx")]
56pub use context::MultiWith;
57#[cfg(feature = "futures")]
58#[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "futures")))]
59pub use runtime::AsyncRuntime;
60pub use value::{ArrayBuffer, TypedArray};
61
62pub mod qjs {
64 pub use rquickjs_sys::*;
66}
67
68#[cfg(feature = "phf")]
69#[doc(hidden)]
70pub mod phf {
71 pub use phf::*;
72}
73
74pub mod prelude {
75 #[cfg(feature = "multi-ctx")]
77 pub use crate::context::MultiWith;
78 pub use crate::{
79 context::Ctx,
80 convert::{Coerced, FromAtom, FromIteratorJs, FromJs, IntoAtom, IntoJs, IteratorJs, List},
81 function::{
82 Exhaustive, Flat, Func, FuncArg, IntoArg, IntoArgs, MutFn, OnceFn, Opt, Rest, This,
83 },
84 result::{CatchResultExt, ThrowResultExt},
85 JsLifetime,
86 };
87 #[cfg(feature = "futures")]
88 #[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "futures")))]
89 pub use crate::{
90 function::Async,
91 promise::{Promise, Promised},
92 };
93}
94
95#[cfg(test)]
96pub(crate) fn test_with<F, R>(func: F) -> R
97where
98 F: FnOnce(Ctx) -> R,
99{
100 let rt = Runtime::new().unwrap();
101 let ctx = Context::full(&rt).unwrap();
102 ctx.with(func)
103}
104
105mod deprecated_features {
106 #[cfg(feature = "properties")]
107 #[allow(unused_imports)]
108 use properties as _;
109 #[cfg(feature = "properties")]
110 #[deprecated(
111 note = "The rquickjs crate feature `properties` is deprecated, the functionality it provided is now enabled by default.
112To remove this warning remove the use of the feature when specifying the dependency."
113 )]
114 mod properties {}
115
116 #[cfg(feature = "array-buffer")]
117 #[allow(unused_imports)]
118 use array_buffer as _;
119 #[cfg(feature = "array-buffer")]
120 #[deprecated(
121 note = "The rquickjs crate feature `array-buffer` is deprecated, the functionality it provided is now enabled by default.
122To remove this warning remove the use of the feature when specifying the dependency."
123 )]
124 mod array_buffer {}
125
126 #[cfg(feature = "classes")]
127 #[allow(unused_imports)]
128 use classes as _;
129 #[cfg(feature = "classes")]
130 #[deprecated(
131 note = "The rquickjs crate feature `classes` is deprecated, the functionality it provided is now enabled by default.
132To remove this warning remove the use of the feature when specifying the dependency."
133 )]
134 mod classes {}
135
136 #[cfg(feature = "allocator")]
137 #[allow(unused_imports)]
138 use allocator as _;
139 #[cfg(feature = "allocator")]
140 #[deprecated(
141 note = "The rquickjs crate feature `allocator` is deprecated, the functionality it provided is now enabled by default.
142To remove this warning remove the use of the feature when specifying the dependency."
143 )]
144 mod allocator {}
145}