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, proxy, Array, Atom, BigInt, CString,
42 Coerced, Constructor, Exception, Filter, FromAtom, FromIteratorJs, FromJs, Function, IntoAtom,
43 IntoJs, IteratorJs, Module, Null, Object, Promise, Proxy, String, Symbol, Type, Undefined,
44 Value, WriteOptions, 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::{
61 ArrayBuffer, ArrayBufferSource, Iterable, IterableFn, JsIterator, TypedArray, U8Clamped,
62};
63
64pub mod qjs {
66 pub use rquickjs_sys::*;
68}
69
70#[cfg(feature = "phf")]
71#[doc(hidden)]
72pub mod phf {
73 pub use phf::*;
74}
75
76pub mod prelude {
77 #[cfg(feature = "multi-ctx")]
79 pub use crate::context::MultiWith;
80 pub use crate::{
81 context::Ctx,
82 convert::{Coerced, FromAtom, FromIteratorJs, FromJs, IntoAtom, IntoJs, IteratorJs, List},
83 function::{
84 Exhaustive, Flat, Func, FuncArg, IntoArg, IntoArgs, MutFn, OnceFn, Opt, Rest, This,
85 },
86 result::{CatchResultExt, ThrowResultExt},
87 JsLifetime,
88 };
89 #[cfg(feature = "futures")]
90 #[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "futures")))]
91 pub use crate::{
92 function::Async,
93 promise::{Promise, Promised},
94 };
95}
96
97#[cfg(test)]
98pub(crate) fn test_with<F, R>(func: F) -> R
99where
100 F: FnOnce(Ctx) -> R,
101{
102 let rt = Runtime::new().unwrap();
103 let ctx = Context::full(&rt).unwrap();
104 ctx.with(func)
105}
106
107mod deprecated_features {
108 #[cfg(feature = "properties")]
109 #[allow(unused_imports)]
110 use properties as _;
111 #[cfg(feature = "properties")]
112 #[deprecated(
113 note = "The rquickjs crate feature `properties` is deprecated, the functionality it provided is now enabled by default.
114To remove this warning remove the use of the feature when specifying the dependency."
115 )]
116 mod properties {}
117
118 #[cfg(feature = "array-buffer")]
119 #[allow(unused_imports)]
120 use array_buffer as _;
121 #[cfg(feature = "array-buffer")]
122 #[deprecated(
123 note = "The rquickjs crate feature `array-buffer` is deprecated, the functionality it provided is now enabled by default.
124To remove this warning remove the use of the feature when specifying the dependency."
125 )]
126 mod array_buffer {}
127
128 #[cfg(feature = "classes")]
129 #[allow(unused_imports)]
130 use classes as _;
131 #[cfg(feature = "classes")]
132 #[deprecated(
133 note = "The rquickjs crate feature `classes` is deprecated, the functionality it provided is now enabled by default.
134To remove this warning remove the use of the feature when specifying the dependency."
135 )]
136 mod classes {}
137
138 #[cfg(feature = "allocator")]
139 #[allow(unused_imports)]
140 use allocator as _;
141 #[cfg(feature = "allocator")]
142 #[deprecated(
143 note = "The rquickjs crate feature `allocator` is deprecated, the functionality it provided is now enabled by default.
144To remove this warning remove the use of the feature when specifying the dependency."
145 )]
146 mod allocator {}
147}