Module conversions

Module conversions 

Source
Expand description

Conversions of Rust values to and from JSVal.

IDL typeType
anyJSVal
booleanbool
bytei8
octetu8
shorti16
unsigned shortu16
longi32
unsigned longu32
long longi64
unsigned long longu64
unrestricted floatf32
floatFinite<f32>
unrestricted doublef64
doubleFinite<f64>
USVStringString
object*mut JSObject
symbol*mut Symbol
nullable typesOption<T>
sequencesVec<T>

MacrosΒ§

impl_as πŸ”’
impl_num πŸ”’

StructsΒ§

ForOfIteratorGuard πŸ”’
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.
Utf8Chars
A wrapper type over crate::jsapi::UTF8Chars. This is created to help transferring a rust string to mozjs. The inner crate::jsapi::UTF8Chars can be accessed via the std::ops::Deref trait.

EnumsΒ§

ConversionBehavior
Behavior for converting out-of-range integers.
ConversionResult
An enum to better support enums through FromJSValConvertible::from_jsval.

TraitsΒ§

As πŸ”’
FromJSValConvertible
A trait to convert JSVals to Rust types.
FromJSValConvertibleRc
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
ToJSValConvertible
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 JSString into a String, regardless of used encoding.
latin1_to_string⚠
Converts a JSString, encoded in β€œLatin1” (i.e. U+0000-U+00FF encoded as 0x00-0xFF) into a String.