[−][src]Struct stdweb::Object
A type representing a JavaScript object.
Methods
impl Object
[src]
pub fn len(&self) -> usize
[src]
Returns the number of elements in this particular object.
pub fn to_iter(&self) -> impl ExactSizeIterator<Item = (String, Value)>
[src]
Retrieves an iterator over this object's keys and values.
When called, this method will pull all the objecy's keys and values from JavaScript, then return an iterator which accesses them in pairs.
Example:
use stdweb::{ js, unstable::TryInto, Object }; let obj: Object = js!( return { [1]: 2 } ).try_into()?; let map: HashMap< i32, i32 > = obj .to_iter() .map( |(k, v)| Ok( ( k.parse()?, v.try_into()? ) ) ) .collect::< Result< _, Box< dyn std::error::Error > > >()?; assert_eq!( map[ &1 ], 2 ); panic!("ahhh");
Trait Implementations
impl JsSerialize for Object
[src]
impl<K, V> TryFrom<BTreeMap<K, V>> for Object where
K: AsRef<str>,
V: JsSerialize,
[src]
K: AsRef<str>,
V: JsSerialize,
type Error = Void
The type returned in the event of a conversion error.
fn try_from(source: BTreeMap<K, V>) -> Result<Self, Self::Error>
[src]
impl<'a, K, V> TryFrom<&'a BTreeMap<K, V>> for Object where
K: AsRef<str>,
V: JsSerialize,
[src]
K: AsRef<str>,
V: JsSerialize,
type Error = Void
The type returned in the event of a conversion error.
fn try_from(source: &'a BTreeMap<K, V>) -> Result<Self, Self::Error>
[src]
impl<'a, K, V> TryFrom<&'a mut BTreeMap<K, V>> for Object where
K: AsRef<str>,
V: JsSerialize,
[src]
K: AsRef<str>,
V: JsSerialize,
type Error = Void
The type returned in the event of a conversion error.
fn try_from(source: &'a mut BTreeMap<K, V>) -> Result<Self, Self::Error>
[src]
impl<K, V> TryFrom<HashMap<K, V, RandomState>> for Object where
K: AsRef<str> + Eq + Hash,
V: JsSerialize,
[src]
K: AsRef<str> + Eq + Hash,
V: JsSerialize,
type Error = Void
The type returned in the event of a conversion error.
fn try_from(source: HashMap<K, V>) -> Result<Self, Self::Error>
[src]
impl<'a, K, V> TryFrom<&'a HashMap<K, V, RandomState>> for Object where
K: AsRef<str> + Eq + Hash,
V: JsSerialize,
[src]
K: AsRef<str> + Eq + Hash,
V: JsSerialize,
type Error = Void
The type returned in the event of a conversion error.
fn try_from(source: &'a HashMap<K, V>) -> Result<Self, Self::Error>
[src]
impl<'a, K, V> TryFrom<&'a mut HashMap<K, V, RandomState>> for Object where
K: AsRef<str> + Eq + Hash,
V: JsSerialize,
[src]
K: AsRef<str> + Eq + Hash,
V: JsSerialize,
type Error = Void
The type returned in the event of a conversion error.
fn try_from(source: &'a mut HashMap<K, V>) -> Result<Self, Self::Error>
[src]
impl TryFrom<Object> for Reference
[src]
type Error = Void
The type returned in the event of a conversion error.
fn try_from(value: Object) -> Result<Self, Self::Error>
[src]
impl TryFrom<Reference> for Object
[src]
type Error = ConversionError
The type returned in the event of a conversion error.
fn try_from(reference: Reference) -> Result<Self, Self::Error>
[src]
impl<'_r> TryFrom<&'_r Reference> for Object
[src]
type Error = ConversionError
The type returned in the event of a conversion error.
fn try_from(reference: &Reference) -> Result<Self, Self::Error>
[src]
impl TryFrom<Value> for Object
[src]
type Error = ConversionError
The type returned in the event of a conversion error.
fn try_from(value: Value) -> Result<Self, Self::Error>
[src]
impl<'_r> TryFrom<&'_r Value> for Object
[src]
type Error = ConversionError
The type returned in the event of a conversion error.
fn try_from(value: &Value) -> Result<Self, Self::Error>
[src]
impl<E: Into<ConversionError>, V: TryFrom<Value, Error = E>> TryFrom<Object> for BTreeMap<String, V>
[src]
type Error = ConversionError
The type returned in the event of a conversion error.
fn try_from(object: Object) -> Result<Self, Self::Error>
[src]
impl<E: Into<ConversionError>, V: TryFrom<Value, Error = E>> TryFrom<Object> for HashMap<String, V>
[src]
type Error = ConversionError
The type returned in the event of a conversion error.
fn try_from(object: Object) -> Result<Self, Self::Error>
[src]
impl InstanceOf for Object
[src]
fn instance_of(reference: &Reference) -> bool
[src]
impl ReferenceType for Object
[src]
unsafe fn from_reference_unchecked(reference: Reference) -> Self
[src]
impl AsRef<Reference> for Object
[src]
impl From<Object> for Reference
[src]
impl From<Object> for BTreeMap<String, Value>
[src]
impl<'a> From<&'a Object> for BTreeMap<String, Value>
[src]
impl<'a> From<&'a mut Object> for BTreeMap<String, Value>
[src]
impl From<Object> for HashMap<String, Value>
[src]
impl<'a> From<&'a Object> for HashMap<String, Value>
[src]
impl<'a> From<&'a mut Object> for HashMap<String, Value>
[src]
impl<K: AsRef<str>, V: JsSerialize> From<BTreeMap<K, V>> for Object
[src]
impl<'a, K, V> From<&'a BTreeMap<K, V>> for Object where
K: AsRef<str>,
V: JsSerialize,
[src]
K: AsRef<str>,
V: JsSerialize,
impl<'a, K, V> From<&'a mut BTreeMap<K, V>> for Object where
K: AsRef<str>,
V: JsSerialize,
[src]
K: AsRef<str>,
V: JsSerialize,
impl<K, V> From<HashMap<K, V, RandomState>> for Object where
K: AsRef<str> + Hash + Eq,
V: JsSerialize,
[src]
K: AsRef<str> + Hash + Eq,
V: JsSerialize,
impl<'a, K, V> From<&'a HashMap<K, V, RandomState>> for Object where
K: AsRef<str> + Hash + Eq,
V: JsSerialize,
[src]
K: AsRef<str> + Hash + Eq,
V: JsSerialize,
impl<'a, K: Hash + Eq, V> From<&'a mut HashMap<K, V, RandomState>> for Object where
K: AsRef<str>,
V: JsSerialize,
[src]
K: AsRef<str>,
V: JsSerialize,
impl Clone for Object
[src]
impl Eq for Object
[src]
impl PartialEq<Object> for Object
[src]
impl Debug for Object
[src]
Auto Trait Implementations
impl Send for Object
impl Sync for Object
impl Unpin for Object
impl UnwindSafe for Object
impl RefUnwindSafe for Object
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,