Struct Reflection

Source
pub struct Reflection(/* private fields */);
Expand description

Perform reflection on a JsValue

Implementations§

Source§

impl Reflection

Source

pub fn new(value: JsValue) -> WalletResult<Self>

Initialize Reflection and check if the value is null or undefined

Source

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

Source

pub fn new_object() -> Self

Initialize Reflection from a js_sys::Object

Source

pub fn take(self) -> JsValue

Consumes Self and returns a JsValue

Source

pub fn set_object_str(&mut self, key: &str, value: &str) -> WalletResult<&Self>

Adds the key value arguments to the object within Self

Source

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

Source

pub fn set_object( &mut self, key: &JsValue, value: &JsValue, ) -> WalletResult<&Self>

Adds the key value arguments to the object within Self

Source

pub fn reflect_inner(&self, key: &str) -> WalletResult<JsValue>

Reflect the key from the value of Self and return the reflected value

Source

pub fn string(&self, key: &str) -> WalletResult<String>

Reflect the key from the value of Self and return the reflected value as a String

Source

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

Source

pub fn into_bytes(self) -> WalletResult<Vec<u8>>

Consume from the value of Self and return it as a Vec of bytes

Source

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

Source

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

Source

pub fn get_array(&self) -> WalletResult<Array>

Return the value of Self as a js_sys::Array without consuming Self

Source

pub fn get_string(value: &JsValue) -> WalletResult<String>

Return a JsValue as a String

Source

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

Source

pub fn reflect_js_array(&self, key: &str) -> WalletResult<Array>

Reflect the key from the value of Self and return the reflected value as a Array

Source

pub fn check_is_undefined(value: &JsValue) -> WalletResult<()>

Check if Self is null or undefined

Source

pub fn get_function(&self, key: &str) -> WalletResult<Function>

Reflect a key from value of Self into a Function

Source

pub fn get_inner(&self) -> &JsValue

Get the value of Self without consuming Self

Source

pub fn js_typeof(value: &JsValue) -> String

Check the JS typeof from a JsValue

Source

pub fn into_function(self) -> WalletResult<Function>

Consume Self and return it’s value as a Function

Source

pub fn into_array(self) -> WalletResult<Array>

Consume Self and return it’s value as an Array

Trait Implementations§

Source§

impl Clone for Reflection

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Reflection

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Reflection

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V