Module mozjs::conversions
source · 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§
- Rooting guard for the iterator field of ForOfIterator. Behaves like RootedGuard (roots on creation, unroots on drop), but borrows and allows access to the whole ForOfIterator, so that methods on ForOfIterator can still be used through it.
Enums§
- Behavior for converting out-of-range integers.
- An enum to better support enums through FromJSValConvertible::from_jsval.
Traits§
- As 🔒
- A trait to convert
JSVal
s to Rust types. - Similar to num_traits, but we use need to be able to customize values
- A trait to convert Rust types to
JSVal
s.
Functions§
- clamp_to 🔒Try to cast the number to a smaller type, but if it doesn’t fit, round it to the MAX or MIN of the source type before casting it to the destination type.
- enforce_range 🔒 ⚠Try to cast the number to a smaller type, but if it doesn’t fit, it will return an error.
- Converts a
JSString
into aString
, regardless of used encoding. - Converts a
JSString
, encoded in “Latin1” (i.e. U+0000-U+00FF encoded as 0x00-0xFF) into aString
.