Trait workflow_wasm::extensions::object::ObjectExtension

source ·
pub trait ObjectExtension {
Show 25 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 get_cast<T>(&self, prop: &str) -> Result<Cast<T>, Error> where T: TryCastFromJs, <T as TryCastFromJs>::Error: Display; fn try_get_cast<T>(&self, prop: &str) -> Result<Option<Cast<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§

source

fn get<T>(&self, prop: &str) -> Result<T, Error>
where T: TryFrom<JsValue>, <T as TryFrom<JsValue>>::Error: Display,

Get a type that implements TryFrom<JsValue> from a property of the Object.

source

fn try_get<T>(&self, prop: &str) -> Result<Option<T>, Error>
where T: TryFrom<JsValue>, <T as TryFrom<JsValue>>::Error: Display,

Try to get a type that implements TryFrom<JsValue> from a property of the Object. Returns Ok(None) if the property does not exist.

source

fn get_cast<T>(&self, prop: &str) -> Result<Cast<T>, Error>

Obtain a Cast from a property of the Object.

source

fn try_get_cast<T>(&self, prop: &str) -> Result<Option<Cast<T>>, Error>

Try to obtain a Cast from a property of the Object. Returns Ok(None) if the property does not exist (null or undefined).

source

fn get_value(&self, prop: &str) -> Result<JsValue, Error>

Get JsValue property

source

fn get_object(&self, prop: &str) -> Result<Object, Error>

Get Object property

source

fn try_get_object(&self, prop: &str) -> Result<Option<Object>, Error>

Get Object property

source

fn try_get_value(&self, prop: &str) -> Result<Option<JsValue>, Error>

Try Get JsValue property

source

fn get_string(&self, prop: &str) -> Result<String, Error>

get String property

source

fn try_get_string(&self, prop: &str) -> Result<Option<String>, Error>

get String property

source

fn get_u8(&self, prop: &str) -> Result<u8, Error>

get Number property as u8

source

fn get_u16(&self, prop: &str) -> Result<u16, Error>

get Number property as u16

source

fn get_u32(&self, prop: &str) -> Result<u32, Error>

get Number property as u32

source

fn get_u64(&self, prop: &str) -> Result<u64, Error>

get Number property as u64

source

fn get_f64(&self, prop: &str) -> Result<f64, Error>

get Number property as f64

source

fn get_bool(&self, prop: &str) -> Result<bool, Error>

get Boolean property as bool

source

fn try_get_bool(&self, prop: &str) -> Result<Option<bool>, Error>

source

fn get_vec(&self, prop: &str) -> Result<Vec<JsValue>, Error>

get property as Vec<JsValue>

source

fn get_vec_u8(&self, prop: &str) -> Result<Vec<u8>, Error>

get Vec<u8> property from a hex string or an Array

source

fn get_vec_u8_from_number_array(&self, prop: &str) -> Result<Vec<u8>, Error>

get Uint8Array property as Vec<u8>

source

fn get_vec_u8_from_uint8_array(&self, prop: &str) -> Result<Vec<u8>, Error>

get Uint8Array property as Vec<u8>

source

fn set(&self, prop: &str, value: &JsValue) -> Result<bool, Error>

set JsValue property

source

fn set_vec(&self, prop: &str, values: &[JsValue]) -> Result<bool, Error>

set Array property from &[JsValue]

source

fn set_properties(&self, props: &[(&str, &JsValue)]) -> Result<(), Error>

set multiple JsValue properties

source

fn delete(&self, prop: &str) -> Result<bool, Error>

delete property

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl ObjectExtension for Object

source§

fn get<T>(&self, prop: &str) -> Result<T, Error>
where T: TryFrom<JsValue>, <T as TryFrom<JsValue>>::Error: Display,

source§

fn try_get<T>(&self, prop: &str) -> Result<Option<T>, Error>
where T: TryFrom<JsValue>, <T as TryFrom<JsValue>>::Error: Display,

source§

fn get_cast<T>(&self, prop: &str) -> Result<Cast<T>, Error>

source§

fn try_get_cast<T>(&self, prop: &str) -> Result<Option<Cast<T>>, Error>

source§

fn get_value(&self, prop: &str) -> Result<JsValue, Error>

source§

fn get_object(&self, prop: &str) -> Result<Object, Error>

source§

fn try_get_object(&self, prop: &str) -> Result<Option<Object>, Error>

source§

fn try_get_value(&self, prop: &str) -> Result<Option<JsValue>, Error>

source§

fn get_string(&self, prop: &str) -> Result<String, Error>

source§

fn try_get_string(&self, prop: &str) -> Result<Option<String>, Error>

source§

fn get_bool(&self, prop: &str) -> Result<bool, Error>

source§

fn try_get_bool(&self, prop: &str) -> Result<Option<bool>, Error>

source§

fn get_u8(&self, prop: &str) -> Result<u8, Error>

source§

fn get_u16(&self, prop: &str) -> Result<u16, Error>

source§

fn get_u32(&self, prop: &str) -> Result<u32, Error>

source§

fn get_u64(&self, prop: &str) -> Result<u64, Error>

source§

fn get_vec(&self, prop: &str) -> Result<Vec<JsValue>, Error>

source§

fn get_vec_u8(&self, prop: &str) -> Result<Vec<u8>, Error>

source§

fn get_vec_u8_from_number_array(&self, prop: &str) -> Result<Vec<u8>, Error>

source§

fn get_vec_u8_from_uint8_array(&self, prop: &str) -> Result<Vec<u8>, Error>

source§

fn get_f64(&self, prop: &str) -> Result<f64, Error>

source§

fn set(&self, prop: &str, value: &JsValue) -> Result<bool, Error>

source§

fn set_vec(&self, prop: &str, values: &[JsValue]) -> Result<bool, Error>

source§

fn set_properties(&self, props: &[(&str, &JsValue)]) -> Result<(), Error>

source§

fn delete(&self, prop: &str) -> Result<bool, Error>

Implementors§