pub trait ObjectExtension {
Show 27 methods
// Required methods
fn get<T>(&self, prop: &str) -> Result<T, Error>
where T: TryFrom<JsValue>,
<T as TryFrom<JsValue>>::Error: Display;
fn try_get<T>(&self, prop: &str) -> Result<Option<T>, Error>
where T: TryFrom<JsValue>,
<T as TryFrom<JsValue>>::Error: Display;
fn cast_into<T>(&self, prop: &str) -> Result<T, Error>
where T: TryCastFromJs,
<T as TryCastFromJs>::Error: Display;
fn cast_from<T>(&self, prop: &str) -> Result<Cast<'static, T>, Error>
where T: TryCastFromJs,
<T as TryCastFromJs>::Error: Display;
fn try_cast_into<T>(&self, prop: &str) -> Result<Option<T>, Error>
where T: TryCastFromJs,
<T as TryCastFromJs>::Error: Display;
fn try_cast_from<T>(
&self,
prop: &str,
) -> Result<Option<Cast<'static, T>>, Error>
where T: TryCastFromJs,
<T as TryCastFromJs>::Error: Display;
fn get_value(&self, prop: &str) -> Result<JsValue, Error>;
fn get_object(&self, prop: &str) -> Result<Object, Error>;
fn try_get_object(&self, prop: &str) -> Result<Option<Object>, Error>;
fn try_get_value(&self, prop: &str) -> Result<Option<JsValue>, Error>;
fn get_string(&self, prop: &str) -> Result<String, Error>;
fn try_get_string(&self, prop: &str) -> Result<Option<String>, Error>;
fn get_u8(&self, prop: &str) -> Result<u8, Error>;
fn get_u16(&self, prop: &str) -> Result<u16, Error>;
fn get_u32(&self, prop: &str) -> Result<u32, Error>;
fn get_u64(&self, prop: &str) -> Result<u64, Error>;
fn get_f64(&self, prop: &str) -> Result<f64, Error>;
fn get_bool(&self, prop: &str) -> Result<bool, Error>;
fn try_get_bool(&self, prop: &str) -> Result<Option<bool>, Error>;
fn get_vec(&self, prop: &str) -> Result<Vec<JsValue>, Error>;
fn get_vec_u8(&self, prop: &str) -> Result<Vec<u8>, Error>;
fn get_vec_u8_from_number_array(&self, prop: &str) -> Result<Vec<u8>, Error>;
fn get_vec_u8_from_uint8_array(&self, prop: &str) -> Result<Vec<u8>, Error>;
fn set(&self, prop: &str, value: &JsValue) -> Result<bool, Error>;
fn set_vec(&self, prop: &str, values: &[JsValue]) -> Result<bool, Error>;
fn set_properties(&self, props: &[(&str, &JsValue)]) -> Result<(), Error>;
fn delete(&self, prop: &str) -> Result<bool, Error>;
}
Expand description
Custom trait implementing simplified property accessor functions for Object
.
Required Methods§
Sourcefn get<T>(&self, prop: &str) -> Result<T, Error>
fn get<T>(&self, prop: &str) -> Result<T, Error>
Get a type that implements TryFrom<JsValue>
from a property of the Object
.
Sourcefn try_get<T>(&self, prop: &str) -> Result<Option<T>, Error>
fn try_get<T>(&self, prop: &str) -> Result<Option<T>, Error>
Try to get a type that implements TryFrom<JsValue>
from a property of the Object
.
Returns Ok(None)
if the property does not exist.
fn cast_from<T>(&self, prop: &str) -> Result<Cast<'static, T>, Error>
fn try_cast_from<T>( &self, prop: &str, ) -> Result<Option<Cast<'static, T>>, Error>
fn try_get_bool(&self, prop: &str) -> Result<Option<bool>, Error>
Sourcefn get_vec_u8(&self, prop: &str) -> Result<Vec<u8>, Error>
fn get_vec_u8(&self, prop: &str) -> Result<Vec<u8>, Error>
get Vec<u8>
property from a hex string or an Array
Sourcefn get_vec_u8_from_number_array(&self, prop: &str) -> Result<Vec<u8>, Error>
fn get_vec_u8_from_number_array(&self, prop: &str) -> Result<Vec<u8>, Error>
get Uint8Array
property as Vec<u8>
Sourcefn get_vec_u8_from_uint8_array(&self, prop: &str) -> Result<Vec<u8>, Error>
fn get_vec_u8_from_uint8_array(&self, prop: &str) -> Result<Vec<u8>, Error>
get Uint8Array
property as Vec<u8>
Sourcefn set_vec(&self, prop: &str, values: &[JsValue]) -> Result<bool, Error>
fn set_vec(&self, prop: &str, values: &[JsValue]) -> Result<bool, Error>
set Array
property from &[JsValue]
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.