Trait workflow_wasm::extensions::object::ObjectExtension
source · pub trait ObjectExtension {
Show 21 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_value(&self, prop: &str) -> Result<JsValue, 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>where
T: TryFrom<JsValue>,
<T as TryFrom<JsValue>>::Error: Display,
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
.
sourcefn try_get<T>(&self, prop: &str) -> Result<Option<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,
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 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]