pub struct Reflection(/* private fields */);
Expand description
Perform reflection on a JsValue
Implementations§
Source§impl Reflection
impl Reflection
Sourcepub fn new(value: JsValue) -> WalletResult<Self>
pub fn new(value: JsValue) -> WalletResult<Self>
Initialize Reflection and check if the value is null or undefined
Sourcepub fn new_from_str(value: &JsValue, key: &str) -> WalletResult<Self>
pub fn new_from_str(value: &JsValue, key: &str) -> WalletResult<Self>
Initialize Reflection from the reflection (js_sys::Reflect) of a value
by getting the value described by key
argument
Sourcepub fn new_object() -> Self
pub fn new_object() -> Self
Initialize Reflection from a js_sys::Object
Sourcepub fn set_object_str(&mut self, key: &str, value: &str) -> WalletResult<&Self>
pub fn set_object_str(&mut self, key: &str, value: &str) -> WalletResult<&Self>
Adds the key
value
arguments to the object within Self
Sourcepub fn set_object_string_optional(
&mut self,
key: &str,
value: Option<&String>,
) -> WalletResult<&Self>
pub fn set_object_string_optional( &mut self, key: &str, value: Option<&String>, ) -> WalletResult<&Self>
Adds the key
value
arguments to the object within Self
Sourcepub fn set_object(
&mut self,
key: &JsValue,
value: &JsValue,
) -> WalletResult<&Self>
pub fn set_object( &mut self, key: &JsValue, value: &JsValue, ) -> WalletResult<&Self>
Adds the key
value
arguments to the object within Self
Sourcepub fn reflect_inner(&self, key: &str) -> WalletResult<JsValue>
pub fn reflect_inner(&self, key: &str) -> WalletResult<JsValue>
Reflect the key
from the value of Self and return the
reflected value
Sourcepub fn string(&self, key: &str) -> WalletResult<String>
pub fn string(&self, key: &str) -> WalletResult<String>
Sourcepub fn get_bytes_from_vec(&self, key: &str) -> WalletResult<Vec<Vec<u8>>>
pub fn get_bytes_from_vec(&self, key: &str) -> WalletResult<Vec<Vec<u8>>>
Reflect the key
from the value of Self and return the
reflected value as a Vec of Vec of bytes
Sourcepub fn into_bytes(self) -> WalletResult<Vec<u8>>
pub fn into_bytes(self) -> WalletResult<Vec<u8>>
Consume from the value of Self and return it as a Vec of bytes
Sourcepub fn reflect_bytes(&self, key: &str) -> WalletResult<Vec<u8>>
pub fn reflect_bytes(&self, key: &str) -> WalletResult<Vec<u8>>
Reflect the key
from the value of Self and return the
reflected value as a Vec of bytes
Sourcepub fn byte32array(&self, key: &str) -> WalletResult<[u8; 32]>
pub fn byte32array(&self, key: &str) -> WalletResult<[u8; 32]>
Reflect the key
from the value of Self and return the
reflected value as a 32 byte array
Sourcepub fn get_array(&self) -> WalletResult<Array>
pub fn get_array(&self) -> WalletResult<Array>
Return the value of Self as a js_sys::Array
without consuming Self
Sourcepub fn get_string(value: &JsValue) -> WalletResult<String>
pub fn get_string(value: &JsValue) -> WalletResult<String>
Sourcepub fn vec_string(&self, key: &str) -> WalletResult<Vec<String>>
pub fn vec_string(&self, key: &str) -> WalletResult<Vec<String>>
Reflect the key
from the value of Self and return the
reflected value as a Vec of String
Sourcepub fn reflect_js_array(&self, key: &str) -> WalletResult<Array>
pub fn reflect_js_array(&self, key: &str) -> WalletResult<Array>
Sourcepub fn check_is_undefined(value: &JsValue) -> WalletResult<()>
pub fn check_is_undefined(value: &JsValue) -> WalletResult<()>
Check if Self is null or undefined