pub struct RawValue(/* private fields */);Expand description
A dynamically-typed, raw value. Does not provide any safety guarantees.
Implementations§
Source§impl RawValue
impl RawValue
Sourcepub unsafe fn get_boolean_unchecked(&self) -> bool
pub unsafe fn get_boolean_unchecked(&self) -> bool
Returns a boolean value without performing any checks.
§Safety
Calling this on a value that isn’t known to be a boolean is undefined behavior.
Sourcepub unsafe fn get_number_unchecked(&self) -> &f64
pub unsafe fn get_number_unchecked(&self) -> &f64
Returns a number value without performing any checks.
§Safety
Calling this on a value that isn’t known to be a number is undefined behavior.
Sourcepub unsafe fn get_raw_string_unchecked(&self) -> GcRaw<String>
pub unsafe fn get_raw_string_unchecked(&self) -> GcRaw<String>
Returns a string value without performing any checks.
§Safety
Calling this on a value that isn’t known to be a string is undefined behavior.
Sourcepub unsafe fn get_raw_function_unchecked(&self) -> GcRaw<Closure>
pub unsafe fn get_raw_function_unchecked(&self) -> GcRaw<Closure>
Returns a function value without performing any checks.
§Safety
Calling this on a value that isn’t known to be a function is undefined behavior.
Sourcepub unsafe fn get_raw_struct_unchecked(&self) -> GcRaw<Struct>
pub unsafe fn get_raw_struct_unchecked(&self) -> GcRaw<Struct>
Returns a struct value without performing any checks.
§Safety
Calling this on a value that isn’t known to be a struct is undefined behavior.
Sourcepub unsafe fn get_raw_trait_unchecked(&self) -> GcRaw<Trait>
pub unsafe fn get_raw_trait_unchecked(&self) -> GcRaw<Trait>
Returns a trait value without performing any checks.
§Safety
Calling this on a value that isn’t known to be a trait is undefined behavior.
Sourcepub unsafe fn get_raw_list_unchecked(&self) -> GcRaw<List>
pub unsafe fn get_raw_list_unchecked(&self) -> GcRaw<List>
Returns a list value without performing any checks.
§Safety
Calling this on a value that isn’t known to be a list is undefined behavior.
Sourcepub unsafe fn get_raw_dict_unchecked(&self) -> GcRaw<Dict>
pub unsafe fn get_raw_dict_unchecked(&self) -> GcRaw<Dict>
Returns a dict value without performing any checks.
§Safety
Calling this on a value that isn’t known to be a dict is undefined behavior.
Sourcepub unsafe fn get_raw_user_data_unchecked(&self) -> GcRaw<Box<dyn UserData>>
pub unsafe fn get_raw_user_data_unchecked(&self) -> GcRaw<Box<dyn UserData>>
Returns a user data value without performing any checks.
§Safety
Calling this on a value that isn’t known to be a user data is undefined behavior.
Sourcepub fn ensure_nil(&self) -> Result<(), ErrorKind>
pub fn ensure_nil(&self) -> Result<(), ErrorKind>
Ensures the value is a Nil, returning a type mismatch error if that’s not the case.
Sourcepub fn ensure_boolean(&self) -> Result<bool, ErrorKind>
pub fn ensure_boolean(&self) -> Result<bool, ErrorKind>
Ensures the value is a Boolean, returning a type mismatch error if that’s not the case.
Sourcepub fn ensure_number(&self) -> Result<f64, ErrorKind>
pub fn ensure_number(&self) -> Result<f64, ErrorKind>
Ensures the value is a Number, returning a type mismatch error if that’s not the case.
Sourcepub fn ensure_raw_string(&self) -> Result<GcRaw<String>, ErrorKind>
pub fn ensure_raw_string(&self) -> Result<GcRaw<String>, ErrorKind>
Ensures the value is a String, returning a type mismatch error if that’s not the case.
Sourcepub fn ensure_raw_function(&self) -> Result<GcRaw<Closure>, ErrorKind>
pub fn ensure_raw_function(&self) -> Result<GcRaw<Closure>, ErrorKind>
Ensures the value is a Function, returning a type mismatch error if that’s not the case.
Sourcepub fn ensure_raw_struct(&self) -> Result<GcRaw<Struct>, ErrorKind>
pub fn ensure_raw_struct(&self) -> Result<GcRaw<Struct>, ErrorKind>
Ensures the value is a Struct, returning a type mismatch error if that’s not the case.
Sourcepub fn ensure_raw_trait(&self) -> Result<GcRaw<Trait>, ErrorKind>
pub fn ensure_raw_trait(&self) -> Result<GcRaw<Trait>, ErrorKind>
Ensures the value is a Trait, returning a type mismatch error if that’s not the case.
Sourcepub fn get_raw_user_data<T>(&self) -> Option<GcRaw<Box<dyn UserData>>>where
T: UserData,
pub fn get_raw_user_data<T>(&self) -> Option<GcRaw<Box<dyn UserData>>>where
T: UserData,
Ensures the value is a UserData of the given type T, returning a type mismatch error
that’s not the case.
Sourcepub fn is_truthy(&self) -> bool
pub fn is_truthy(&self) -> bool
Returns whether the value is truthy. All values except Nil and False are truthy.