Expand description
Conversions of Rust values to and from JSVal.
| IDL type | Type |
|---|---|
| any | JSVal |
| boolean | bool |
| byte | i8 |
| octet | u8 |
| short | i16 |
| unsigned short | u16 |
| long | i32 |
| unsigned long | u32 |
| long long | i64 |
| unsigned long long | u64 |
| unrestricted float | f32 |
| float | Finite<f32> |
| unrestricted double | f64 |
| double | Finite<f64> |
| USVString | String |
| object | *mut JSObject |
| symbol | *mut Symbol |
| nullable types | Option<T> |
| sequences | Vec<T> |
Macros§
Structs§
- Utf8
Chars - A wrapper type over
crate::jsapi::UTF8Chars. This is created to help transferring a rust string to mozjs. The innercrate::jsapi::UTF8Charscan be accessed via thestd::ops::Dereftrait.
Enums§
- Conversion
Behavior - Behavior for converting out-of-range integers.
- Conversion
Result - An enum to better support enums through FromJSValConvertible::from_jsval.
Traits§
- As 🔒
- FromJS
ValConvertible - A trait to convert
JSVals to Rust types. - FromJS
ValConvertible Rc - A trait to convert
JSVals to Rust types inside of Rc wrappers. - Number
- Similar to num_traits, but we use need to be able to customize values
- ToJS
ValConvertible - A trait to convert Rust types to
JSVals.
Functions§
- clamp_
to 🔒 - WebIDL ConvertToInt (Clamp) conversion. Spec: https://webidl.spec.whatwg.org/#abstract-opdef-converttoint
- convert_
int_ 🔒 ⚠from_ jsval - enforce_
range 🔒 ⚠ - Try to cast the number to a smaller type, but if it doesn’t fit, it will return an error.
- jsstr_
to_ ⚠string - Converts a
JSStringinto aString, regardless of used encoding. - latin1_
to_ ⚠string - Converts a
JSString, encoded in “Latin1” (i.e. U+0000-U+00FF encoded as 0x00-0xFF) into aString.